@grapesjs/studio-sdk-plugins 1.0.36 → 1.0.38-rc.0

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 (97) hide show
  1. package/dist/accordionComponent/index.cjs.js +4 -4
  2. package/dist/accordionComponent/index.es.js +83 -70
  3. package/dist/accordionComponent/index.umd.js +5 -5
  4. package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
  5. package/dist/aiChat/components/utils.d.ts +1 -0
  6. package/dist/aiChat/components/utilsTw.d.ts +11 -0
  7. package/dist/aiChat/index.cjs.js +85 -85
  8. package/dist/aiChat/index.es.js +11151 -10258
  9. package/dist/aiChat/index.js +85 -85
  10. package/dist/aiChat/index.umd.js +86 -86
  11. package/dist/aiChat/locales/en.d.ts +11 -0
  12. package/dist/aiChat/projectGeneration.d.ts +17 -0
  13. package/dist/aiChat/server/index.cjs.js +1 -1
  14. package/dist/aiChat/server/index.es.js +1 -1
  15. package/dist/aiChat/server/index.js +1 -1
  16. package/dist/aiChat/server/index.umd.js +1 -1
  17. package/dist/aiChat/types.d.ts +1 -1
  18. package/dist/animationComponent/index.cjs.js +3 -3
  19. package/dist/animationComponent/index.es.js +57 -44
  20. package/dist/animationComponent/index.umd.js +3 -3
  21. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  22. package/dist/canvasAbsoluteMode/index.es.js +63 -50
  23. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  24. package/dist/canvasEmptyState/index.cjs.js +1 -1
  25. package/dist/canvasEmptyState/index.es.js +60 -47
  26. package/dist/canvasEmptyState/index.umd.js +1 -1
  27. package/dist/canvasFullSize/index.cjs.js +3 -3
  28. package/dist/canvasFullSize/index.es.js +49 -36
  29. package/dist/canvasFullSize/index.umd.js +5 -5
  30. package/dist/canvasGridMode/index.cjs.js +2 -2
  31. package/dist/canvasGridMode/index.es.js +251 -233
  32. package/dist/canvasGridMode/index.umd.js +4 -4
  33. package/dist/canvasScreenshot/index.cjs.js +1 -1
  34. package/dist/canvasScreenshot/index.es.js +42 -29
  35. package/dist/canvasScreenshot/index.umd.js +1 -1
  36. package/dist/dataSourceEjs/index.cjs.js +3 -3
  37. package/dist/dataSourceEjs/index.es.js +51 -38
  38. package/dist/dataSourceEjs/index.umd.js +3 -3
  39. package/dist/dataSourceHandlebars/index.cjs.js +2 -2
  40. package/dist/dataSourceHandlebars/index.es.js +152 -139
  41. package/dist/dataSourceHandlebars/index.umd.js +4 -4
  42. package/dist/dialogComponent/index.cjs.js +9 -9
  43. package/dist/dialogComponent/index.es.js +73 -60
  44. package/dist/dialogComponent/index.umd.js +3 -3
  45. package/dist/flexComponent/index.cjs.js +6 -6
  46. package/dist/flexComponent/index.es.js +83 -70
  47. package/dist/flexComponent/index.umd.js +6 -6
  48. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  49. package/dist/fsLightboxComponent/index.es.js +67 -54
  50. package/dist/fsLightboxComponent/index.umd.js +2 -2
  51. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  52. package/dist/googleFontsAssetProvider/index.es.js +92 -79
  53. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  54. package/dist/iconifyComponent/index.cjs.js +2 -2
  55. package/dist/iconifyComponent/index.es.js +52 -39
  56. package/dist/iconifyComponent/index.umd.js +2 -2
  57. package/dist/index.cjs.js +42 -42
  58. package/dist/index.es.js +1167 -1149
  59. package/dist/index.umd.js +42 -42
  60. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  61. package/dist/layoutSidebarButtons/index.es.js +82 -69
  62. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  63. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  64. package/dist/lightGalleryComponent/index.es.js +98 -85
  65. package/dist/lightGalleryComponent/index.umd.js +1 -1
  66. package/dist/linkImageComponent/index.cjs.js +2 -2
  67. package/dist/linkImageComponent/index.es.js +71 -58
  68. package/dist/linkImageComponent/index.umd.js +2 -2
  69. package/dist/listPagesComponent/index.cjs.js +3 -3
  70. package/dist/listPagesComponent/index.es.js +49 -36
  71. package/dist/listPagesComponent/index.umd.js +3 -3
  72. package/dist/presetPrintable/index.cjs.js +5 -5
  73. package/dist/presetPrintable/index.es.js +126 -113
  74. package/dist/presetPrintable/index.umd.js +4 -4
  75. package/dist/prosemirror/index.cjs.js +1 -1
  76. package/dist/prosemirror/index.es.js +97 -84
  77. package/dist/prosemirror/index.umd.js +1 -1
  78. package/dist/rendererReact/index.cjs.js +1 -1
  79. package/dist/rendererReact/index.es.js +149 -137
  80. package/dist/rendererReact/index.js +1 -1
  81. package/dist/rendererReact/index.umd.js +1 -1
  82. package/dist/rteTinyMce/index.cjs.js +2 -2
  83. package/dist/rteTinyMce/index.es.js +92 -79
  84. package/dist/rteTinyMce/index.umd.js +2 -2
  85. package/dist/shapeDividerComponent/index.cjs.js +3 -3
  86. package/dist/shapeDividerComponent/index.es.js +38 -25
  87. package/dist/shapeDividerComponent/index.umd.js +3 -3
  88. package/dist/swiperComponent/index.cjs.js +5 -5
  89. package/dist/swiperComponent/index.es.js +106 -93
  90. package/dist/swiperComponent/index.umd.js +5 -5
  91. package/dist/tableComponent/index.cjs.js +1 -1
  92. package/dist/tableComponent/index.es.js +167 -154
  93. package/dist/tableComponent/index.umd.js +1 -1
  94. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  95. package/dist/youtubeAssetProvider/index.es.js +35 -22
  96. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  97. package/package.json +2 -2
@@ -1 +1 @@
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;
1
+ "use strict";const y=require("react/jsx-runtime"),h=require("react"),_=require("react-dom/client"),G="app.grapesjs.com",I="app-stage.grapesjs.com",F="app2.grapesjs.com",M="app-stage2.grapesjs.com",D=[G,F,I,M,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],W="license:check:end",$=()=>typeof window<"u",K=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?I:G}`}/${o?"platform-api":"api"}`,S=()=>{if(!$())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},V=()=>{const e=S();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},z=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function q(e){return typeof e=="function"}async function J({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:a,body:n}){const r=`${t||K({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=a?new URLSearchParams(a).toString():"",d=u?`?${u}`:"",p=await fetch(`${r}${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.openEditCode="studio:openEditCode",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 H(e){const t=e;return t.init=o=>s=>e(s,o),t}const Z=e=>H(e);async function Q({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:a,cleanup:n}){let i="",r;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n()},u=(p={})=>{var R;const{error:g,sdkLicense:f}=p,l=(R=p.plan)==null?void 0:R.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],A=L[l];w>A&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(x.settings)&&(r=e.runCommand(x.settings),i=(r==null?void 0:r.baseUrl)||"");const d=p=>{a==null||a(p),p&&u(p)};if(!r){e.onReady(async()=>{if(!V())if(s){const p=await Y({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const p=X(r);d(p);return}e.on(W,p=>d(p))}const X=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Y(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await J({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}function ee(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=z(o);t[s]=e[o]}return t}const te=(e,t)=>{const o=e.components||{};for(const s in o){const a=o[s];if(a.component===t)return{cmpConfig:a,type:s}}};function j(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const a=e[s];if(typeof a=="string"||typeof a=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=a,o=!0}}return o?t:void 0}function oe(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const a=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(a&&n){const i=a.replace(/-([a-z])/g,r=>r[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function ne(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=oe(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,a=o.value;if(typeof s=="string"&&s&&a!==void 0&&a!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=a}}}),Object.keys(t).length>0?t:void 0}}}function se(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function re(e){var o;const t={};for(const[s,a]of Object.entries(e))if(s==="style")t.style=ne(a);else if(s.startsWith("data-"))t[s]=a;else{const n=se(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ie.has(n)||n.startsWith("svg")?t[n]=a:!ae.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=a:t[n]=a}return t}const ae=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"]),ie=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"},E=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ce(e){return t=>{const o=t.getContent();E(o)&&t.set({content:P({...e,model:o}),reactContent:o})}}const le=e=>t=>{const o=t.component;E(o)&&(t.component={components:P({...e,model:o})})};function P(e){const{model:t,editor:o,config:s}=e;if(E(t)){const a=t,n={},{type:i,props:r={}}=a,{children:c,className:u,style:d,...p}=r,g=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(q(i)){const l=te(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=ee(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 pe(e){const{component:t}=e,[o,s]=h.useState(0),[a,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const r=()=>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,r),t.on(f,c),()=>{t.off(g,r),t.off(f,c),c()}},[t]),{key:o,view:a,connectDom:r=>{if(!r)return;const c=ue({...e,el:r});n(c)}}}function ue(e){var c;const{editor:t,component:o,el:s,frameView:a}=e,{em:n,Components:i}=t;let r=o.getView(a.model);if((r==null?void 0:r.el)===s)return r;if(!r){const{ComponentView:u}=i,d=o.attributes.type||"default",p=((c=i.getType(d))==null?void 0:c.view)||u,g={...i.config,frameView:a,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}});r=new f({el:s,config:g,model:o})}return r.el=s,r.render(),r}function fe(e,t){const{Components:o}=e,s=({id:a,model:n})=>{n&&o.addType(a,{model:{toJSON(...i){const r=n.prototype.toJSON.apply(this,i);return r.tagName=this.tagName,r}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([a,n])=>{var g,f;const{allowPropClassName:i,allowPropId:r,allowChildren:c}=n,u=!r&&!i,d=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!r});o.addType(a,{isComponent:l=>(l==null?void 0:l.tagName)===a,model:{defaults:{type:a,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 C(e){var O;const{component:t,config:o,editor:s,frameView:a,onMount:n,tagName:i,children:r}=e,{key:c,view:u,connectDom:d}=pe(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(),R=m.length?m.map(v=>y.jsx(C,{component:v,config:o,editor:s,frameView:a},v.cid)):[g||void 0],w=re(t.getAttributes()),A=f==null?void 0:f.editorRender,T=[...R,r].filter(v=>v??!1),k=T.length?T:null;if(A)return y.jsx(A,{props:w,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,{...w,children:k})});if(t.isInstanceOf("textnode"))return g;const U=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:d,key:U},t.get("void")?null:k)}const de=e=>{const{frame:t,window:o,onMount:s,editor:a}=e,n=a.Canvas.events,{root:i}=t;try{const r=_.createRoot(o.document.body);r.render(y.jsx(ge,{...e,component:i,onMount:s}));const c=()=>r.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(r){console.warn(r)}return i.getView()};function ge(e){const{editor:t,component:o,window:s,frameView:a,config:n,onMount:i}=e,r=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:r,editor:t,frameView:a}}:{},d=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(C,{tagName:"div",component:o,config:n,editor:t,frameView:a,onMount:i,children:y.jsx(d,{...u})})})}const ye="rendererReact",he=b.startup,ve=function(e,t={}){const{Blocks:o,Pages:s}=e,a=o.events,n=s.events;e.Canvas.config.customRenderer=r=>de({...r,config:t}),e.Components.config.processor=r=>P({model:r,editor:e,config:t}),fe(e,t);const i=[[a.add,ce({editor:e,config:t})],[n.addBefore,le({editor:e,config:t})]];i.forEach(([r,c])=>e.on(r,c)),Q({editor:e,licenseKey:t.licenseKey,plan:he,pluginName:ye,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([r,c])=>e.off(r,c))}})},be=Z(ve);module.exports=be;
@@ -1 +1 @@
1
- (function(y,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(require("react/jsx-runtime"),require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","react","react-dom/client"],h):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_rendererReact=h(y.jsxRuntime,y.React,y.ReactDOMClient))})(this,function(y,h,_){"use strict";const x="app.grapesjs.com",O="app-stage.grapesjs.com",D=[x,"app2.grapesjs.com",O,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],U="license:check:end",j=()=>typeof window<"u",F=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?O:x}`}/${o?"platform-api":"api"}`,S=()=>{const e=j()&&window.location.hostname;return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},W=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function $(e){return typeof e=="function"}async function K({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:r,body:n}){const a=`${t||F({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():"",f=u?`?${u}`:"",p=await fetch(`${a}${f}`,c);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||{}),k=(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))(k||{});const L={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function V(e){const t=e;return t.init=o=>s=>e(s,o),t}const z=e=>V(e);async function q({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 A;const{error:g,sdkLicense:d}=p,l=(A=p.plan)==null?void 0:A.category;if(!(d||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],P=L[l];w>P&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(k.settings)&&(a=e.runCommand(k.settings),i=(a==null?void 0:a.baseUrl)||"");const f=p=>{r==null||r(p),p&&u(p)};if(!a){e.onReady(async()=>{if(!S())if(s){const p=await H({licenseKey:s,pluginName:o,baseApiUrl:i});f(p)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const p=J(a);f(p);return}e.on(U,p=>f(p))}const J=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function H(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await K({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 Z(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=W(o);t[s]=e[o]}return t}const Q=(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 I(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 X(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 Y(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return I(e);if(typeof e=="string"){let t=X(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=I(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 ee(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function te(e){var o;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=Y(r);else if(s.startsWith("data-"))t[s]=r;else{const n=ee(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ne.has(n)||n.startsWith("svg")?t[n]=r:!oe.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=r:t[n]=r}return t}const oe=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"]),ne=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 se(e){return t=>{const o=t.getContent();T(o)&&t.set({content:R({...e,model:o}),reactContent:o})}}const re=e=>t=>{const o=t.component;T(o)&&(t.component={components:R({...e,model:o})})};function R(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:f,...p}=a,g=l=>({type:"textnode",content:l}),d=typeof i=="symbol";if($(i)){const l=Q(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:d||(n.tagName=i);if(u&&(n.classes=u),f&&(n.style=Z(f)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):R({...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 ae(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,f=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${f.update}:${l}`),"rerender"].join(" "),d=[f.removed,"rerender"].join(" ");return t.on(g,a),t.on(d,c),()=>{t.off(g,a),t.off(d,c),c()}},[t]),{key:o,view:r,connectDom:a=>{if(!a)return;const c=ie({...e,el:a});n(c)}}}function ie(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,f=o.attributes.type||"default",p=((c=i.getType(f))==null?void 0:c.view)||u,g={...i.config,frameView:r,em:n},d=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 d({el:s,config:g,model:o})}return a.el=s,a.render(),a}function ce(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,d;const{allowPropClassName:i,allowPropId:a,allowChildren:c}=n,u=!a&&!i,f=()=>({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:f,selectorManager:p,...((d=n.model)==null?void 0:d.defaults)||{}}}})})}function C(e){var M;const{component:t,config:o,editor:s,frameView:r,onMount:n,tagName:i,children:a}=e,{key:c,view:u,connectDom:f}=ae(e);h.useEffect(()=>{if(!u&&!n)return;const b=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(b)},[u]);const p=t.get("type")||"default",g=t.content,d=(M=o.components)==null?void 0:M[p],l=(d==null?void 0:d.component)||i||t.tagName||"div",m=t.components(),A=m.length?m.map(b=>y.jsx(C,{component:b,config:o,editor:s,frameView:r},b.cid)):[g||void 0],w=te(t.getAttributes()),P=d==null?void 0:d.editorRender,G=[...A,a].filter(b=>b??!1),E=G.length?G:null;if(P)return y.jsx(P,{props:w,editor:s,component:t,connectDom:f,children:E});if(d!=null&&d.component)return y.jsx("gjs-wrapper",{ref:f,style:d.wrapperStyle,children:y.jsx(l,{...w,children:E})});if(t.isInstanceOf("textnode"))return g;const fe=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:f,key:fe},t.get("void")?null:E)}const le=e=>{const{frame:t,window:o,onMount:s,editor:r}=e,n=r.Canvas.events,{root:i}=t;try{const a=_.createRoot(o.document.body);a.render(y.jsx(pe,{...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 pe(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}}:{},f=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(C,{tagName:"div",component:o,config:n,editor:t,frameView:r,onMount:i,children:y.jsx(f,{...u})})})}const ue="rendererReact",de=v.startup;return z(function(e,t={}){const{Blocks:o,Pages:s}=e,r=o.events,n=s.events;e.Canvas.config.customRenderer=a=>le({...a,config:t}),e.Components.config.processor=a=>R({model:a,editor:e,config:t}),ce(e,t);const i=[[r.add,se({editor:e,config:t})],[n.addBefore,re({editor:e,config:t})]];i.forEach(([a,c])=>e.on(a,c)),q({editor:e,licenseKey:t.licenseKey,plan:de,pluginName:ue,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([a,c])=>e.off(a,c))}})})});
1
+ (function(y,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(require("react/jsx-runtime"),require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","react","react-dom/client"],h):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_rendererReact=h(y.jsxRuntime,y.React,y.ReactDOMClient))})(this,function(y,h,U){"use strict";const x="app.grapesjs.com",O="app-stage.grapesjs.com",D=[x,"app2.grapesjs.com",O,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],j="license:check:end",M=()=>typeof window<"u",F=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?O:x}`}/${o?"platform-api":"api"}`,W=()=>{if(!M())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},S=()=>{const e=W();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},$=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function K(e){return typeof e=="function"}async function V({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:a,body:n}){const r=`${t||F({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=a?new URLSearchParams(a).toString():"",f=u?`?${u}`:"",p=await fetch(`${r}${f}`,c);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||{}),k=(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.openEditCode="studio:openEditCode",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))(k||{});const L={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function z(e){const t=e;return t.init=o=>s=>e(s,o),t}const q=e=>z(e);async function J({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:a,cleanup:n}){let i="",r;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n()},u=(p={})=>{var A;const{error:g,sdkLicense:d}=p,l=(A=p.plan)==null?void 0:A.category;if(!(d||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],P=L[l];w>P&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(k.settings)&&(r=e.runCommand(k.settings),i=(r==null?void 0:r.baseUrl)||"");const f=p=>{a==null||a(p),p&&u(p)};if(!r){e.onReady(async()=>{if(!S())if(s){const p=await Z({licenseKey:s,pluginName:o,baseApiUrl:i});f(p)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const p=H(r);f(p);return}e.on(j,p=>f(p))}const H=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Z(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await V({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}function Q(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=$(o);t[s]=e[o]}return t}const X=(e,t)=>{const o=e.components||{};for(const s in o){const a=o[s];if(a.component===t)return{cmpConfig:a,type:s}}};function I(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const a=e[s];if(typeof a=="string"||typeof a=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=a,o=!0}}return o?t:void 0}function Y(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const a=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(a&&n){const i=a.replace(/-([a-z])/g,r=>r[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function ee(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return I(e);if(typeof e=="string"){let t=Y(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=I(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,a=o.value;if(typeof s=="string"&&s&&a!==void 0&&a!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=a}}}),Object.keys(t).length>0?t:void 0}}}function te(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function oe(e){var o;const t={};for(const[s,a]of Object.entries(e))if(s==="style")t.style=ee(a);else if(s.startsWith("data-"))t[s]=a;else{const n=te(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||se.has(n)||n.startsWith("svg")?t[n]=a:!ne.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=a:t[n]=a}return t}const ne=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"]),se=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 re(e){return t=>{const o=t.getContent();T(o)&&t.set({content:R({...e,model:o}),reactContent:o})}}const ae=e=>t=>{const o=t.component;T(o)&&(t.component={components:R({...e,model:o})})};function R(e){const{model:t,editor:o,config:s}=e;if(T(t)){const a=t,n={},{type:i,props:r={}}=a,{children:c,className:u,style:f,...p}=r,g=l=>({type:"textnode",content:l}),d=typeof i=="symbol";if(K(i)){const l=X(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:d||(n.tagName=i);if(u&&(n.classes=u),f&&(n.style=Q(f)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):R({...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 ie(e){const{component:t}=e,[o,s]=h.useState(0),[a,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const r=()=>s(l=>l+1),c=()=>{[...t.views].forEach(m=>m.remove()),n(void 0)},{em:u}=t,f=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${f.update}:${l}`),"rerender"].join(" "),d=[f.removed,"rerender"].join(" ");return t.on(g,r),t.on(d,c),()=>{t.off(g,r),t.off(d,c),c()}},[t]),{key:o,view:a,connectDom:r=>{if(!r)return;const c=ce({...e,el:r});n(c)}}}function ce(e){var c;const{editor:t,component:o,el:s,frameView:a}=e,{em:n,Components:i}=t;let r=o.getView(a.model);if((r==null?void 0:r.el)===s)return r;if(!r){const{ComponentView:u}=i,f=o.attributes.type||"default",p=((c=i.getType(f))==null?void 0:c.view)||u,g={...i.config,frameView:a,em:n},d=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}});r=new d({el:s,config:g,model:o})}return r.el=s,r.render(),r}function le(e,t){const{Components:o}=e,s=({id:a,model:n})=>{n&&o.addType(a,{model:{toJSON(...i){const r=n.prototype.toJSON.apply(this,i);return r.tagName=this.tagName,r}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([a,n])=>{var g,d;const{allowPropClassName:i,allowPropId:r,allowChildren:c}=n,u=!r&&!i,f=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!r});o.addType(a,{isComponent:l=>(l==null?void 0:l.tagName)===a,model:{defaults:{type:a,traits:((g=n.props)==null?void 0:g.call(n))||[],droppable:!!c,stylable:!u,styleManager:f,selectorManager:p,...((d=n.model)==null?void 0:d.defaults)||{}}}})})}function G(e){var _;const{component:t,config:o,editor:s,frameView:a,onMount:n,tagName:i,children:r}=e,{key:c,view:u,connectDom:f}=ie(e);h.useEffect(()=>{if(!u&&!n)return;const b=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(b)},[u]);const p=t.get("type")||"default",g=t.content,d=(_=o.components)==null?void 0:_[p],l=(d==null?void 0:d.component)||i||t.tagName||"div",m=t.components(),A=m.length?m.map(b=>y.jsx(G,{component:b,config:o,editor:s,frameView:a},b.cid)):[g||void 0],w=oe(t.getAttributes()),P=d==null?void 0:d.editorRender,C=[...A,r].filter(b=>b??!1),E=C.length?C:null;if(P)return y.jsx(P,{props:w,editor:s,component:t,connectDom:f,children:E});if(d!=null&&d.component)return y.jsx("gjs-wrapper",{ref:f,style:d.wrapperStyle,children:y.jsx(l,{...w,children:E})});if(t.isInstanceOf("textnode"))return g;const ge=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:f,key:ge},t.get("void")?null:E)}const pe=e=>{const{frame:t,window:o,onMount:s,editor:a}=e,n=a.Canvas.events,{root:i}=t;try{const r=U.createRoot(o.document.body);r.render(y.jsx(ue,{...e,component:i,onMount:s}));const c=()=>r.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(r){console.warn(r)}return i.getView()};function ue(e){const{editor:t,component:o,window:s,frameView:a,config:n,onMount:i}=e,r=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:r,editor:t,frameView:a}}:{},f=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(G,{tagName:"div",component:o,config:n,editor:t,frameView:a,onMount:i,children:y.jsx(f,{...u})})})}const de="rendererReact",fe=v.startup;return q(function(e,t={}){const{Blocks:o,Pages:s}=e,a=o.events,n=s.events;e.Canvas.config.customRenderer=r=>pe({...r,config:t}),e.Components.config.processor=r=>R({model:r,editor:e,config:t}),le(e,t);const i=[[a.add,re({editor:e,config:t})],[n.addBefore,ae({editor:e,config:t})]];i.forEach(([r,c])=>e.on(r,c)),J({editor:e,licenseKey:t.licenseKey,plan:fe,pluginName:de,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([r,c])=>e.off(r,c))}})})});
@@ -1,4 +1,4 @@
1
- "use strict";var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{}),y=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",t.dialogImportCode="studio:dialogImportCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.settings="studio:settings",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(y||{}),L=(t=>(t.dark="dark",t.light="light",t.auto="auto",t))(L||{});const I="app.grapesjs.com",O="app-stage.grapesjs.com",M="app2.grapesjs.com",B="app-stage2.grapesjs.com",k=[I,M,O,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],N="license:check:end",U=()=>typeof window<"u",j=({isDev:t,isStage:s,isPlatform:n})=>`${t?"":`https://${s?O:I}`}/${n?"platform-api":"api"}`,F=()=>{const t=U()&&window.location.hostname;return!!t&&(k.includes(t)||k.some(s=>t.endsWith(s)))};async function W({path:t,baseApiUrl:s,method:n="GET",headers:i={},params:a,body:c}){const r=`${s||j({isDev:!1,isStage:!1})}${t}`,l={method:n,headers:{"Content-Type":"application/json",...i}};c&&(l.body=JSON.stringify(c));const b=a?new URLSearchParams(a).toString():"",e=b?`?${b}`:"",o=await fetch(`${r}${e}`,l);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}const _={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function $(t){const s=t;return s.init=n=>i=>t(i,n),s}const C=t=>$(t);async function q({editor:t,plan:s,pluginName:n,licenseKey:i,onLicenseCheckResponse:a,cleanup:c}){let d="",r;const l=o=>{console.warn("Cleanup plugin:",n,"Reason:",o),c()},b=(o={})=>{var w;const{error:u,sdkLicense:x}=o,g=(w=o.plan)==null?void 0:w.category;if(!(x||o.license)||u)l(u||"Invalid license");else if(g){const p=_[s],R=_[g];p>R&&l({pluginRequiredPlan:s,licensePlan:g})}};t.Commands.has(y.settings)&&(r=t.runCommand(y.settings),d=(r==null?void 0:r.baseUrl)||"");const e=o=>{a==null||a(o),o&&b(o)};if(!r){t.onReady(async()=>{if(!F())if(i){const o=await H({licenseKey:i,pluginName:n,baseApiUrl:d});e(o)}else l("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const o=K(r);e(o);return}t.on(N,o=>e(o))}const K=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function H(t){const{licenseKey:s,pluginName:n,baseApiUrl:i}=t;try{return(await W({baseApiUrl:i,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const z=(t,s,n)=>{const{doc:i=document}=n,a=n.target||i.head,c=a.querySelector(`style[${t}]`)||i.createElement("style");c.setAttribute(t,"true"),c.innerHTML=s,!a.contains(c)&&a.appendChild(c)},S=t=>t.dispatchEvent(new CustomEvent("input"));function V(t,s){if(!s)return()=>{};const n=t.Components.events,i=e=>t.getSelectedAll().includes(e),a=e=>e.isInstanceOf("text")&&!e.isChildOf("text"),c=e=>e.isChildOf("text"),d=e=>t.getEditing()===e,r=(e,o={})=>{e.trigger("focus",o.event)},l=(e,o)=>{i(e)&&a(e)&&!d(e)&&r(e,o)},b=(e,o)=>{if(i(e)&&!a(e)&&c(e)){const u=e.parents().find(x=>x.isInstanceOf("text"));u&&(r(u,o),setTimeout(()=>t.select(u),0))}};return t.on(n.select,l),t.on(n.selectBefore,b),()=>{t.off(n.select,l),t.off(n.selectBefore,b)}}const J="rteTinyMce",X=v.startup,Y=`
1
+ "use strict";var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{}),y=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",t.dialogImportCode="studio:dialogImportCode",t.openEditCode="studio:openEditCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.settings="studio:settings",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(y||{}),L=(t=>(t.dark="dark",t.light="light",t.auto="auto",t))(L||{});const I="app.grapesjs.com",O="app-stage.grapesjs.com",M="app2.grapesjs.com",B="app-stage2.grapesjs.com",k=[I,M,O,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],N="license:check:end",U=()=>typeof window<"u",j=({isDev:t,isStage:s,isPlatform:n})=>`${t?"":`https://${s?O:I}`}/${n?"platform-api":"api"}`,F=()=>{if(!U())return"";const{hostname:t}=window.location;if(t)return t;try{return window.parent.location.hostname||""}catch{return""}},W=()=>{const t=F();return!!t&&(k.includes(t)||k.some(s=>t.endsWith(s)))};async function $({path:t,baseApiUrl:s,method:n="GET",headers:i={},params:a,body:l}){const r=`${s||j({isDev:!1,isStage:!1})}${t}`,c={method:n,headers:{"Content-Type":"application/json",...i}};l&&(c.body=JSON.stringify(l));const b=a?new URLSearchParams(a).toString():"",e=b?`?${b}`:"",o=await fetch(`${r}${e}`,c);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}const _={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function C(t){const s=t;return s.init=n=>i=>t(i,n),s}const q=t=>C(t);async function H({editor:t,plan:s,pluginName:n,licenseKey:i,onLicenseCheckResponse:a,cleanup:l}){let d="",r;const c=o=>{console.warn("Cleanup plugin:",n,"Reason:",o),l()},b=(o={})=>{var w;const{error:u,sdkLicense:p}=o,g=(w=o.plan)==null?void 0:w.category;if(!(p||o.license)||u)c(u||"Invalid license");else if(g){const x=_[s],R=_[g];x>R&&c({pluginRequiredPlan:s,licensePlan:g})}};t.Commands.has(y.settings)&&(r=t.runCommand(y.settings),d=(r==null?void 0:r.baseUrl)||"");const e=o=>{a==null||a(o),o&&b(o)};if(!r){t.onReady(async()=>{if(!W())if(i){const o=await z({licenseKey:i,pluginName:n,baseApiUrl:d});e(o)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const o=K(r);e(o);return}t.on(N,o=>e(o))}const K=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function z(t){const{licenseKey:s,pluginName:n,baseApiUrl:i}=t;try{return(await $({baseApiUrl:i,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const V=(t,s,n)=>{const{doc:i=document}=n,a=n.target||i.head,l=a.querySelector(`style[${t}]`)||i.createElement("style");l.setAttribute(t,"true"),l.innerHTML=s,!a.contains(l)&&a.appendChild(l)},J=t=>t.dispatchEvent(new CustomEvent("input"));function S(t,s){if(!s)return()=>{};const n=t.Components.events,i=e=>t.getSelectedAll().includes(e),a=e=>e.isInstanceOf("text")&&!e.isChildOf("text"),l=e=>e.isChildOf("text"),d=e=>t.getEditing()===e,r=(e,o={})=>{e.trigger("focus",o.event)},c=(e,o)=>{i(e)&&a(e)&&!d(e)&&r(e,o)},b=(e,o)=>{if(i(e)&&!a(e)&&l(e)){const u=e.parents().find(p=>p.isInstanceOf("text"));u&&(r(u,o),setTimeout(()=>t.select(u),0))}};return t.on(n.select,c),t.on(n.selectBefore,b),()=>{t.off(n.select,c),t.off(n.selectBefore,b)}}const X="rteTinyMce",Y=v.startup,Q=`
2
2
  .tox .tox-toolbar,
3
3
  .tox .tox-toolbar__overflow,
4
4
  .tox .tox-toolbar__primary,
@@ -101,4 +101,4 @@
101
101
  background-color: var(--gs-theme-cl-prm-bg1);
102
102
  border-color: var(--gs-theme-cl-prm-bg3);
103
103
  opacity: 0.75;
104
- }`,E=new WeakMap,Q=(t,s)=>{E.set(t,s)},Z=t=>{E.delete(t)},T=t=>E.get(t),m=t=>{const s=t.target,n=s.closest(".tox"),i=s.matches(".ephox-snooker-resizer-bar");(n||i)&&t.stopPropagation()},D=t=>{t.stopPropagation(),t.preventDefault()},tt=(t,s)=>{const n=t.getDoc(),i=t.getWin();if(s!=null&&s.event){const{event:a}=s,{clientX:c,clientY:d}=a;let r;if(n.caretRangeFromPoint)r=n.caretRangeFromPoint(c,d);else if(n.caretPositionFromPoint){const l=n.caretPositionFromPoint(c,d);r=n.createRange(),r==null||r.setStart(l.offsetNode,l.offset)}if(r){const l=i.getSelection();l==null||l.removeAllRanges(),l==null||l.addRange(r),t.selection.setRng(r)}}else t.execCommand("SelectAll")},et=t=>{var b,e;const{el:s,editor:n,componentView:i}=t,a=n.runCommand(y.getStateTheme),c=i.model,d={target:s,inline:!0,skin:(a==null?void 0:a.theme)===L.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},r=((e=(b=t.pluginOpts)==null?void 0:b.loadConfig)==null?void 0:e.call(b,{config:d,editor:n,componentView:i,component:c}))||{};return{...d,...r}},A=(t,s=document)=>new Promise((n,i)=>{const a=Array.isArray(t)?[...t]:[t],{head:c}=s,d=r=>{if(r.length){const l=s.createElement("script");l.src=r.shift(),l.onload=d.bind(null,r),l.onerror=i,c.appendChild(l)}else n()};d(a)}),ot=function(t,s={}){const n={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...s},{cdnScript:i}=n,a=t.Canvas.events,c=!n.skipCustomTheme,d="gs-plg-tinymce-studio-theme",r=async(e,o)=>{const u=e.ownerDocument,x=u.defaultView,g=o==null?void 0:o.view;if(!x||!g){console.warn("Missing required data",{win:x,componentView:g});return}const h=et({el:e,editor:t,componentView:g,pluginOpts:n}),p=(await x.tinymce.init(h))[0];if(!p)return;const G=(await window.tinymce.init({...h,target:document.createElement("div")}))[0];return p.ui.show(),u.body.addEventListener("mousedown",m),document.body.addEventListener("mousedown",m),p.on("Change",()=>S(e)),p.on("blur",()=>p.ui.show()),p.on("OpenWindow",function(){var P;const f=(P=u.querySelector(".tox-dialog"))==null?void 0:P.closest(".tox");f&&(f==null?void 0:f.ownerDocument)!==document&&(document.body.appendChild(f),p.once("CloseWindow",()=>{f&&f.ownerDocument===document&&u.body.appendChild(f)}))}),e.addEventListener("dragstart",D,{capture:!0}),t.runCommand(y.setStateContextMenu,{enabled:!1}),tt(p,o),{rteEditor:p,rteEditorShallow:G}},l=(e,o)=>{e.ownerDocument.body.removeEventListener("mousedown",m),document.body.removeEventListener("mousedown",m),e.removeEventListener("dragstart",D,{capture:!0}),t.runCommand(y.setStateContextMenu,{enabled:!0}),o.rteEditor.destroy(),o.rteEditorShallow.destroy()};t.on(a.frameLoad,async({window:e})=>{const o=e.document;A(i,o)}),t.onReady(()=>{A(i,document),c&&z(d,Y,{target:document.body})}),t.setCustomRte({parseContent:!0,async enable(e,o,u){const x=T(e);if(x)return x.rteEditor;const g=await r(e,u);return g&&Q(e,g),g==null?void 0:g.rteEditor},disable(e){const o=T(e);o&&(Z(e),l(e,o))},getContent(e,o,u){var h;const x=T(e),g=x==null?void 0:x.rteEditor;return g&&!g.isDirty()?u.view.lastContent:g?(h=g.getContent)==null?void 0:h.call(g):e.innerHTML}});const b=V(t,n.enableOnClick);q({editor:t,licenseKey:n.licenseKey,plan:X,pluginName:J,cleanup:()=>{t.RichTextEditor.customRte=void 0,b()}})},nt=C(ot);module.exports=nt;
104
+ }`,T=new WeakMap,Z=(t,s)=>{T.set(t,s)},tt=t=>{T.delete(t)},E=t=>T.get(t),m=t=>{const s=t.target,n=s.closest(".tox"),i=s.matches(".ephox-snooker-resizer-bar");(n||i)&&t.stopPropagation()},D=t=>{t.stopPropagation(),t.preventDefault()},et=(t,s)=>{const n=t.getDoc(),i=t.getWin();if(s!=null&&s.event){const{event:a}=s,{clientX:l,clientY:d}=a;let r;if(n.caretRangeFromPoint)r=n.caretRangeFromPoint(l,d);else if(n.caretPositionFromPoint){const c=n.caretPositionFromPoint(l,d);r=n.createRange(),r==null||r.setStart(c.offsetNode,c.offset)}if(r){const c=i.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(r),t.selection.setRng(r)}}else t.execCommand("SelectAll")},ot=t=>{var b,e;const{el:s,editor:n,componentView:i}=t,a=n.runCommand(y.getStateTheme),l=i.model,d={target:s,inline:!0,skin:(a==null?void 0:a.theme)===L.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},r=((e=(b=t.pluginOpts)==null?void 0:b.loadConfig)==null?void 0:e.call(b,{config:d,editor:n,componentView:i,component:l}))||{};return{...d,...r}},A=(t,s=document)=>new Promise((n,i)=>{const a=Array.isArray(t)?[...t]:[t],{head:l}=s,d=r=>{if(r.length){const c=s.createElement("script");c.src=r.shift(),c.onload=d.bind(null,r),c.onerror=i,l.appendChild(c)}else n()};d(a)}),nt=function(t,s={}){const n={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...s},{cdnScript:i}=n,a=t.Canvas.events,l=!n.skipCustomTheme,d="gs-plg-tinymce-studio-theme",r=async(e,o)=>{const u=e.ownerDocument,p=u.defaultView,g=o==null?void 0:o.view;if(!p||!g){console.warn("Missing required data",{win:p,componentView:g});return}const h=ot({el:e,editor:t,componentView:g,pluginOpts:n}),x=(await p.tinymce.init(h))[0];if(!x)return;const G=(await window.tinymce.init({...h,target:document.createElement("div")}))[0];return x.ui.show(),u.body.addEventListener("mousedown",m),document.body.addEventListener("mousedown",m),x.on("Change",()=>J(e)),x.on("blur",()=>x.ui.show()),x.on("OpenWindow",function(){var P;const f=(P=u.querySelector(".tox-dialog"))==null?void 0:P.closest(".tox");f&&(f==null?void 0:f.ownerDocument)!==document&&(document.body.appendChild(f),x.once("CloseWindow",()=>{f&&f.ownerDocument===document&&u.body.appendChild(f)}))}),e.addEventListener("dragstart",D,{capture:!0}),t.runCommand(y.setStateContextMenu,{enabled:!1}),et(x,o),{rteEditor:x,rteEditorShallow:G}},c=(e,o)=>{e.ownerDocument.body.removeEventListener("mousedown",m),document.body.removeEventListener("mousedown",m),e.removeEventListener("dragstart",D,{capture:!0}),t.runCommand(y.setStateContextMenu,{enabled:!0}),o.rteEditor.destroy(),o.rteEditorShallow.destroy()};t.on(a.frameLoad,async({window:e})=>{const o=e.document;A(i,o)}),t.onReady(()=>{A(i,document),l&&V(d,Q,{target:document.body})}),t.setCustomRte({parseContent:!0,async enable(e,o,u){const p=E(e);if(p)return p.rteEditor;const g=await r(e,u);return g&&Z(e,g),g==null?void 0:g.rteEditor},disable(e){const o=E(e);o&&(tt(e),c(e,o))},getContent(e,o,u){var h;const p=E(e),g=p==null?void 0:p.rteEditor;return g&&!g.isDirty()?u.view.lastContent:g?(h=g.getContent)==null?void 0:h.call(g):e.innerHTML}});const b=S(t,n.enableOnClick);H({editor:t,licenseKey:n.licenseKey,plan:Y,pluginName:X,cleanup:()=>{t.RichTextEditor.customRte=void 0,b()}})},st=q(nt);module.exports=st;
@@ -1,4 +1,4 @@
1
- var v = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(v || {}), y = /* @__PURE__ */ ((t) => (t.toastAdd = "studio:toastAdd", t.toastRemove = "studio:toastRemove", t.dialogOpen = "studio:dialogOpen", t.dialogClose = "studio:dialogClose", t.dialogExportCode = "studio:dialogExportCode", t.dialogImportCode = "studio:dialogImportCode", t.sidebarLeftSet = "studio:sidebarLeft:set", t.sidebarLeftGet = "studio:sidebarLeft:get", t.sidebarLeftToggle = "studio:sidebarLeft:toggle", t.sidebarRightSet = "studio:sidebarRight:set", t.sidebarRightGet = "studio:sidebarRight:get", t.sidebarRightToggle = "studio:sidebarRight:toggle", t.sidebarTopSet = "studio:sidebarTop:set", t.sidebarTopGet = "studio:sidebarTop:get", t.sidebarTopToggle = "studio:sidebarTop:toggle", t.sidebarBottomSet = "studio:sidebarBottom:set", t.sidebarBottomGet = "studio:sidebarBottom:get", t.sidebarBottomToggle = "studio:sidebarBottom:toggle", t.symbolAdd = "studio:symbolAdd", t.symbolDetach = "studio:symbolDetach", t.symbolOverride = "studio:symbolOverride", t.symbolPropagateStyles = "studio:propagateStyles", t.getPagesConfig = "studio:getPagesConfig", t.setPagesConfig = "studio:setPagesConfig", t.getPageSettings = "studio:getPageSettings", t.setPageSettings = "studio:setPageSettings", t.clearPage = "studio:clearPage", t.projectFiles = "studio:projectFiles", t.validateCode = "studio:validateCode", t.canvasReload = "studio:canvasReload", t.getBlocksPanel = "studio:getBlocksPanel", t.setBlocksPanel = "studio:setBlocksPanel", t.getStateContextMenu = "studio:getStateContextMenu", t.setStateContextMenu = "studio:setStateContextMenu", t.contextMenuComponent = "studio:contextMenuComponent", t.layoutAdd = "studio:layoutAdd", t.layoutRemove = "studio:layoutRemove", t.layoutToggle = "studio:layoutToggle", t.layoutUpdate = "studio:layoutUpdate", t.layoutGet = "studio:layoutGet", t.layoutConfigGet = "studio:layoutConfigGet", t.layoutConfigSet = "studio:layoutConfigSet", t.layoutComponentAdd = "studio:layoutComponentAdd", t.layoutComponentGet = "studio:layoutComponentGet", t.layoutComponentRemove = "studio:layoutComponentRemove", t.layoutComponentRender = "studio:layoutComponentRender", t.getStateTheme = "studio:getStateTheme", t.setStateTheme = "studio:setStateTheme", t.settings = "studio:settings", t.assetProviderGet = "studio:assetProviderGet", t.assetProviderAdd = "studio:assetProviderAdd", t.assetProviderRemove = "studio:assetProviderRemove", t.fontGet = "studio:fontGet", t.fontAdd = "studio:fontAdd", t.fontRemove = "studio:fontRemove", t.fontManagerOpen = "studio:fontManagerOpen", t.menuFontLoad = "studio:menuFontLoad", t.toggleStateDataSource = "studio:toggleStateDataSource", t.getStateDataSource = "studio:getStateDataSource", t.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", t.dataSourceSetImporter = "studio:dataSourceSetImporter", t.dataSourceSetExporter = "studio:dataSourceSetExporter", t.setDragAbsolute = "studio:setDragAbsolute", t))(y || {}), L = /* @__PURE__ */ ((t) => (t.dark = "dark", t.light = "light", t.auto = "auto", t))(L || {});
1
+ var v = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(v || {}), y = /* @__PURE__ */ ((t) => (t.toastAdd = "studio:toastAdd", t.toastRemove = "studio:toastRemove", t.dialogOpen = "studio:dialogOpen", t.dialogClose = "studio:dialogClose", t.dialogExportCode = "studio:dialogExportCode", t.dialogImportCode = "studio:dialogImportCode", t.openEditCode = "studio:openEditCode", t.sidebarLeftSet = "studio:sidebarLeft:set", t.sidebarLeftGet = "studio:sidebarLeft:get", t.sidebarLeftToggle = "studio:sidebarLeft:toggle", t.sidebarRightSet = "studio:sidebarRight:set", t.sidebarRightGet = "studio:sidebarRight:get", t.sidebarRightToggle = "studio:sidebarRight:toggle", t.sidebarTopSet = "studio:sidebarTop:set", t.sidebarTopGet = "studio:sidebarTop:get", t.sidebarTopToggle = "studio:sidebarTop:toggle", t.sidebarBottomSet = "studio:sidebarBottom:set", t.sidebarBottomGet = "studio:sidebarBottom:get", t.sidebarBottomToggle = "studio:sidebarBottom:toggle", t.symbolAdd = "studio:symbolAdd", t.symbolDetach = "studio:symbolDetach", t.symbolOverride = "studio:symbolOverride", t.symbolPropagateStyles = "studio:propagateStyles", t.getPagesConfig = "studio:getPagesConfig", t.setPagesConfig = "studio:setPagesConfig", t.getPageSettings = "studio:getPageSettings", t.setPageSettings = "studio:setPageSettings", t.clearPage = "studio:clearPage", t.projectFiles = "studio:projectFiles", t.validateCode = "studio:validateCode", t.canvasReload = "studio:canvasReload", t.getBlocksPanel = "studio:getBlocksPanel", t.setBlocksPanel = "studio:setBlocksPanel", t.getStateContextMenu = "studio:getStateContextMenu", t.setStateContextMenu = "studio:setStateContextMenu", t.contextMenuComponent = "studio:contextMenuComponent", t.layoutAdd = "studio:layoutAdd", t.layoutRemove = "studio:layoutRemove", t.layoutToggle = "studio:layoutToggle", t.layoutUpdate = "studio:layoutUpdate", t.layoutGet = "studio:layoutGet", t.layoutConfigGet = "studio:layoutConfigGet", t.layoutConfigSet = "studio:layoutConfigSet", t.layoutComponentAdd = "studio:layoutComponentAdd", t.layoutComponentGet = "studio:layoutComponentGet", t.layoutComponentRemove = "studio:layoutComponentRemove", t.layoutComponentRender = "studio:layoutComponentRender", t.getStateTheme = "studio:getStateTheme", t.setStateTheme = "studio:setStateTheme", t.settings = "studio:settings", t.assetProviderGet = "studio:assetProviderGet", t.assetProviderAdd = "studio:assetProviderAdd", t.assetProviderRemove = "studio:assetProviderRemove", t.fontGet = "studio:fontGet", t.fontAdd = "studio:fontAdd", t.fontRemove = "studio:fontRemove", t.fontManagerOpen = "studio:fontManagerOpen", t.menuFontLoad = "studio:menuFontLoad", t.toggleStateDataSource = "studio:toggleStateDataSource", t.getStateDataSource = "studio:getStateDataSource", t.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", t.dataSourceSetImporter = "studio:dataSourceSetImporter", t.dataSourceSetExporter = "studio:dataSourceSetExporter", t.setDragAbsolute = "studio:setDragAbsolute", t))(y || {}), L = /* @__PURE__ */ ((t) => (t.dark = "dark", t.light = "light", t.auto = "auto", t))(L || {});
2
2
  const I = "app.grapesjs.com", O = "app-stage.grapesjs.com", M = "app2.grapesjs.com", B = "app-stage2.grapesjs.com", k = [
3
3
  I,
4
4
  M,
@@ -10,33 +10,46 @@ const I = "app.grapesjs.com", O = "app-stage.grapesjs.com", M = "app2.grapesjs.c
10
10
  // For stackblitz.com demos
11
11
  ".local.webcontainer.io",
12
12
  // For stackblitz.com demos
13
- "-sandpack.codesandbox.io"
13
+ "-sandpack.codesandbox.io",
14
14
  // For Sandpack demos
15
+ ".claudemcpcontent.com",
16
+ // For Claude mcp app
17
+ ".web-sandbox.oaiusercontent.com"
18
+ // For OpenAI mcp app
15
19
  ], N = "license:check:end", U = () => typeof window < "u", j = ({
16
20
  isDev: t,
17
21
  isStage: s,
18
22
  isPlatform: n
19
23
  }) => `${t ? "" : `https://${s ? O : I}`}/${n ? "platform-api" : "api"}`, F = () => {
20
- const t = U() && window.location.hostname;
24
+ if (!U()) return "";
25
+ const { hostname: t } = window.location;
26
+ if (t) return t;
27
+ try {
28
+ return window.parent.location.hostname || "";
29
+ } catch {
30
+ return "";
31
+ }
32
+ }, W = () => {
33
+ const t = F();
21
34
  return !!t && (k.includes(t) || k.some((s) => t.endsWith(s)));
22
35
  };
23
- async function W({
36
+ async function $({
24
37
  path: t,
25
38
  baseApiUrl: s,
26
39
  method: n = "GET",
27
40
  headers: i = {},
28
41
  params: a,
29
- body: c
42
+ body: l
30
43
  }) {
31
- const r = `${s || j({ isDev: !1, isStage: !1 })}${t}`, l = {
44
+ const r = `${s || j({ isDev: !1, isStage: !1 })}${t}`, c = {
32
45
  method: n,
33
46
  headers: {
34
47
  "Content-Type": "application/json",
35
48
  ...i
36
49
  }
37
50
  };
38
- c && (l.body = JSON.stringify(c));
39
- const b = a ? new URLSearchParams(a).toString() : "", e = b ? `?${b}` : "", o = await fetch(`${r}${e}`, l);
51
+ l && (c.body = JSON.stringify(l));
52
+ const b = a ? new URLSearchParams(a).toString() : "", e = b ? `?${b}` : "", o = await fetch(`${r}${e}`, c);
40
53
  if (!o.ok)
41
54
  throw new Error(`HTTP error! status: ${o.status}`);
42
55
  return o.json();
@@ -47,30 +60,30 @@ const _ = {
47
60
  [v.business]: 20,
48
61
  [v.enterprise]: 30
49
62
  };
50
- function $(t) {
63
+ function C(t) {
51
64
  const s = t;
52
65
  return s.init = (n) => (i) => t(i, n), s;
53
66
  }
54
- const C = (t) => /* @__PURE__ */ $(t);
55
- async function q({
67
+ const q = (t) => /* @__PURE__ */ C(t);
68
+ async function H({
56
69
  editor: t,
57
70
  plan: s,
58
71
  pluginName: n,
59
72
  licenseKey: i,
60
73
  onLicenseCheckResponse: a,
61
- cleanup: c
74
+ cleanup: l
62
75
  }) {
63
76
  let d = "", r;
64
- const l = (o) => {
65
- console.warn("Cleanup plugin:", n, "Reason:", o), c();
77
+ const c = (o) => {
78
+ console.warn("Cleanup plugin:", n, "Reason:", o), l();
66
79
  }, b = (o = {}) => {
67
80
  var w;
68
- const { error: u, sdkLicense: x } = o, g = (w = o.plan) == null ? void 0 : w.category;
69
- if (!(x || o.license) || u)
70
- l(u || "Invalid license");
81
+ const { error: u, sdkLicense: p } = o, g = (w = o.plan) == null ? void 0 : w.category;
82
+ if (!(p || o.license) || u)
83
+ c(u || "Invalid license");
71
84
  else if (g) {
72
- const p = _[s], R = _[g];
73
- p > R && l({ pluginRequiredPlan: s, licensePlan: g });
85
+ const x = _[s], R = _[g];
86
+ x > R && c({ pluginRequiredPlan: s, licensePlan: g });
74
87
  }
75
88
  };
76
89
  t.Commands.has(y.settings) && (r = t.runCommand(y.settings), d = (r == null ? void 0 : r.baseUrl) || "");
@@ -79,12 +92,12 @@ async function q({
79
92
  };
80
93
  if (!r) {
81
94
  t.onReady(async () => {
82
- if (!F())
95
+ if (!W())
83
96
  if (i) {
84
- const o = await H({ licenseKey: i, pluginName: n, baseApiUrl: d });
97
+ const o = await z({ licenseKey: i, pluginName: n, baseApiUrl: d });
85
98
  e(o);
86
99
  } else
87
- l("The `licenseKey` option not provided");
100
+ c("The `licenseKey` option not provided");
88
101
  });
89
102
  return;
90
103
  }
@@ -101,10 +114,10 @@ const K = (t) => ({
101
114
  error: t.licenseError,
102
115
  plan: t.licensePlan
103
116
  });
104
- async function H(t) {
117
+ async function z(t) {
105
118
  const { licenseKey: s, pluginName: n, baseApiUrl: i } = t;
106
119
  try {
107
- return (await W({
120
+ return (await $({
108
121
  baseApiUrl: i,
109
122
  path: `/sdk/${s || "na"}`,
110
123
  method: "POST",
@@ -117,28 +130,28 @@ async function H(t) {
117
130
  return console.error("Error during SDK license check:", a), !1;
118
131
  }
119
132
  }
120
- const z = (t, s, n) => {
121
- const { doc: i = document } = n, a = n.target || i.head, c = a.querySelector(`style[${t}]`) || i.createElement("style");
122
- c.setAttribute(t, "true"), c.innerHTML = s, !a.contains(c) && a.appendChild(c);
123
- }, S = (t) => t.dispatchEvent(new CustomEvent("input"));
124
- function V(t, s) {
133
+ const V = (t, s, n) => {
134
+ const { doc: i = document } = n, a = n.target || i.head, l = a.querySelector(`style[${t}]`) || i.createElement("style");
135
+ l.setAttribute(t, "true"), l.innerHTML = s, !a.contains(l) && a.appendChild(l);
136
+ }, J = (t) => t.dispatchEvent(new CustomEvent("input"));
137
+ function S(t, s) {
125
138
  if (!s) return () => {
126
139
  };
127
- const n = t.Components.events, i = (e) => t.getSelectedAll().includes(e), a = (e) => e.isInstanceOf("text") && !e.isChildOf("text"), c = (e) => e.isChildOf("text"), d = (e) => t.getEditing() === e, r = (e, o = {}) => {
140
+ const n = t.Components.events, i = (e) => t.getSelectedAll().includes(e), a = (e) => e.isInstanceOf("text") && !e.isChildOf("text"), l = (e) => e.isChildOf("text"), d = (e) => t.getEditing() === e, r = (e, o = {}) => {
128
141
  e.trigger("focus", o.event);
129
- }, l = (e, o) => {
142
+ }, c = (e, o) => {
130
143
  i(e) && a(e) && !d(e) && r(e, o);
131
144
  }, b = (e, o) => {
132
- if (i(e) && !a(e) && c(e)) {
133
- const u = e.parents().find((x) => x.isInstanceOf("text"));
145
+ if (i(e) && !a(e) && l(e)) {
146
+ const u = e.parents().find((p) => p.isInstanceOf("text"));
134
147
  u && (r(u, o), setTimeout(() => t.select(u), 0));
135
148
  }
136
149
  };
137
- return t.on(n.select, l), t.on(n.selectBefore, b), () => {
138
- t.off(n.select, l), t.off(n.selectBefore, b);
150
+ return t.on(n.select, c), t.on(n.selectBefore, b), () => {
151
+ t.off(n.select, c), t.off(n.selectBefore, b);
139
152
  };
140
153
  }
141
- const J = "rteTinyMce", X = v.startup, Y = `
154
+ const X = "rteTinyMce", Y = v.startup, Q = `
142
155
  .tox .tox-toolbar,
143
156
  .tox .tox-toolbar__overflow,
144
157
  .tox .tox-toolbar__primary,
@@ -241,35 +254,35 @@ const J = "rteTinyMce", X = v.startup, Y = `
241
254
  background-color: var(--gs-theme-cl-prm-bg1);
242
255
  border-color: var(--gs-theme-cl-prm-bg3);
243
256
  opacity: 0.75;
244
- }`, E = /* @__PURE__ */ new WeakMap(), Q = (t, s) => {
245
- E.set(t, s);
246
- }, Z = (t) => {
247
- E.delete(t);
248
- }, T = (t) => E.get(t), m = (t) => {
257
+ }`, T = /* @__PURE__ */ new WeakMap(), Z = (t, s) => {
258
+ T.set(t, s);
259
+ }, tt = (t) => {
260
+ T.delete(t);
261
+ }, E = (t) => T.get(t), m = (t) => {
249
262
  const s = t.target, n = s.closest(".tox"), i = s.matches(".ephox-snooker-resizer-bar");
250
263
  (n || i) && t.stopPropagation();
251
264
  }, D = (t) => {
252
265
  t.stopPropagation(), t.preventDefault();
253
- }, tt = (t, s) => {
266
+ }, et = (t, s) => {
254
267
  const n = t.getDoc(), i = t.getWin();
255
268
  if (s != null && s.event) {
256
- const { event: a } = s, { clientX: c, clientY: d } = a;
269
+ const { event: a } = s, { clientX: l, clientY: d } = a;
257
270
  let r;
258
271
  if (n.caretRangeFromPoint)
259
- r = n.caretRangeFromPoint(c, d);
272
+ r = n.caretRangeFromPoint(l, d);
260
273
  else if (n.caretPositionFromPoint) {
261
- const l = n.caretPositionFromPoint(c, d);
262
- r = n.createRange(), r == null || r.setStart(l.offsetNode, l.offset);
274
+ const c = n.caretPositionFromPoint(l, d);
275
+ r = n.createRange(), r == null || r.setStart(c.offsetNode, c.offset);
263
276
  }
264
277
  if (r) {
265
- const l = i.getSelection();
266
- l == null || l.removeAllRanges(), l == null || l.addRange(r), t.selection.setRng(r);
278
+ const c = i.getSelection();
279
+ c == null || c.removeAllRanges(), c == null || c.addRange(r), t.selection.setRng(r);
267
280
  }
268
281
  } else
269
282
  t.execCommand("SelectAll");
270
- }, et = (t) => {
283
+ }, ot = (t) => {
271
284
  var b, e;
272
- const { el: s, editor: n, componentView: i } = t, a = n.runCommand(y.getStateTheme), c = i.model, d = {
285
+ const { el: s, editor: n, componentView: i } = t, a = n.runCommand(y.getStateTheme), l = i.model, d = {
273
286
  target: s,
274
287
  inline: !0,
275
288
  skin: (a == null ? void 0 : a.theme) === L.dark ? "oxide-dark" : "oxide",
@@ -286,86 +299,86 @@ const J = "rteTinyMce", X = v.startup, Y = `
286
299
  plugins: "advlist autolink lists link image media table",
287
300
  toolbar_mode: "sliding",
288
301
  toolbar: "bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"
289
- }, r = ((e = (b = t.pluginOpts) == null ? void 0 : b.loadConfig) == null ? void 0 : e.call(b, { config: d, editor: n, componentView: i, component: c })) || {};
302
+ }, r = ((e = (b = t.pluginOpts) == null ? void 0 : b.loadConfig) == null ? void 0 : e.call(b, { config: d, editor: n, componentView: i, component: l })) || {};
290
303
  return {
291
304
  ...d,
292
305
  ...r
293
306
  };
294
307
  }, A = (t, s = document) => new Promise((n, i) => {
295
- const a = Array.isArray(t) ? [...t] : [t], { head: c } = s, d = (r) => {
308
+ const a = Array.isArray(t) ? [...t] : [t], { head: l } = s, d = (r) => {
296
309
  if (r.length) {
297
- const l = s.createElement("script");
298
- l.src = r.shift(), l.onload = d.bind(null, r), l.onerror = i, c.appendChild(l);
310
+ const c = s.createElement("script");
311
+ c.src = r.shift(), c.onload = d.bind(null, r), c.onerror = i, l.appendChild(c);
299
312
  } else
300
313
  n();
301
314
  };
302
315
  d(a);
303
- }), ot = function(t, s = {}) {
316
+ }), nt = function(t, s = {}) {
304
317
  const n = {
305
318
  cdnScript: "https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",
306
319
  ...s
307
- }, { cdnScript: i } = n, a = t.Canvas.events, c = !n.skipCustomTheme, d = "gs-plg-tinymce-studio-theme", r = async (e, o) => {
308
- const u = e.ownerDocument, x = u.defaultView, g = o == null ? void 0 : o.view;
309
- if (!x || !g) {
310
- console.warn("Missing required data", { win: x, componentView: g });
320
+ }, { cdnScript: i } = n, a = t.Canvas.events, l = !n.skipCustomTheme, d = "gs-plg-tinymce-studio-theme", r = async (e, o) => {
321
+ const u = e.ownerDocument, p = u.defaultView, g = o == null ? void 0 : o.view;
322
+ if (!p || !g) {
323
+ console.warn("Missing required data", { win: p, componentView: g });
311
324
  return;
312
325
  }
313
- const h = et({
326
+ const h = ot({
314
327
  el: e,
315
328
  editor: t,
316
329
  componentView: g,
317
330
  pluginOpts: n
318
- }), p = (await x.tinymce.init(h))[0];
319
- if (!p) return;
331
+ }), x = (await p.tinymce.init(h))[0];
332
+ if (!x) return;
320
333
  const G = (await window.tinymce.init({
321
334
  ...h,
322
335
  target: document.createElement("div")
323
336
  }))[0];
324
- return p.ui.show(), u.body.addEventListener("mousedown", m), document.body.addEventListener("mousedown", m), p.on("Change", () => S(e)), p.on("blur", () => p.ui.show()), p.on("OpenWindow", function() {
337
+ return x.ui.show(), u.body.addEventListener("mousedown", m), document.body.addEventListener("mousedown", m), x.on("Change", () => J(e)), x.on("blur", () => x.ui.show()), x.on("OpenWindow", function() {
325
338
  var P;
326
339
  const f = (P = u.querySelector(".tox-dialog")) == null ? void 0 : P.closest(".tox");
327
- f && (f == null ? void 0 : f.ownerDocument) !== document && (document.body.appendChild(f), p.once("CloseWindow", () => {
340
+ f && (f == null ? void 0 : f.ownerDocument) !== document && (document.body.appendChild(f), x.once("CloseWindow", () => {
328
341
  f && f.ownerDocument === document && u.body.appendChild(f);
329
342
  }));
330
- }), e.addEventListener("dragstart", D, { capture: !0 }), t.runCommand(y.setStateContextMenu, { enabled: !1 }), tt(p, o), { rteEditor: p, rteEditorShallow: G };
331
- }, l = (e, o) => {
343
+ }), e.addEventListener("dragstart", D, { capture: !0 }), t.runCommand(y.setStateContextMenu, { enabled: !1 }), et(x, o), { rteEditor: x, rteEditorShallow: G };
344
+ }, c = (e, o) => {
332
345
  e.ownerDocument.body.removeEventListener("mousedown", m), document.body.removeEventListener("mousedown", m), e.removeEventListener("dragstart", D, { capture: !0 }), t.runCommand(y.setStateContextMenu, { enabled: !0 }), o.rteEditor.destroy(), o.rteEditorShallow.destroy();
333
346
  };
334
347
  t.on(a.frameLoad, async ({ window: e }) => {
335
348
  const o = e.document;
336
349
  A(i, o);
337
350
  }), t.onReady(() => {
338
- A(i, document), c && z(d, Y, { target: document.body });
351
+ A(i, document), l && V(d, Q, { target: document.body });
339
352
  }), t.setCustomRte({
340
353
  parseContent: !0,
341
354
  // @ts-expect-error - Type 'CustomRteOptions' is missing the following properties from type 'CustomRteOptions': editor, component, el
342
355
  async enable(e, o, u) {
343
- const x = T(e);
344
- if (x) return x.rteEditor;
356
+ const p = E(e);
357
+ if (p) return p.rteEditor;
345
358
  const g = await r(e, u);
346
- return g && Q(e, g), g == null ? void 0 : g.rteEditor;
359
+ return g && Z(e, g), g == null ? void 0 : g.rteEditor;
347
360
  },
348
361
  disable(e) {
349
- const o = T(e);
350
- o && (Z(e), l(e, o));
362
+ const o = E(e);
363
+ o && (tt(e), c(e, o));
351
364
  },
352
365
  getContent(e, o, u) {
353
366
  var h;
354
- const x = T(e), g = x == null ? void 0 : x.rteEditor;
367
+ const p = E(e), g = p == null ? void 0 : p.rteEditor;
355
368
  return g && !g.isDirty() ? u.view.lastContent : g ? (h = g.getContent) == null ? void 0 : h.call(g) : e.innerHTML;
356
369
  }
357
370
  });
358
- const b = V(t, n.enableOnClick);
359
- q({
371
+ const b = S(t, n.enableOnClick);
372
+ H({
360
373
  editor: t,
361
374
  licenseKey: n.licenseKey,
362
- plan: X,
363
- pluginName: J,
375
+ plan: Y,
376
+ pluginName: X,
364
377
  cleanup: () => {
365
378
  t.RichTextEditor.customRte = void 0, b();
366
379
  }
367
380
  });
368
- }, rt = C(ot);
381
+ }, at = q(nt);
369
382
  export {
370
- rt as default
383
+ at as default
371
384
  };