@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +175 -162
  3. package/dist/accordionComponent/index.umd.js +7 -7
  4. package/dist/aiChat/index.cjs.js +64 -64
  5. package/dist/aiChat/index.es.js +5785 -5757
  6. package/dist/aiChat/index.js +64 -64
  7. package/dist/aiChat/index.umd.js +63 -63
  8. package/dist/animationComponent/index.cjs.js +3 -3
  9. package/dist/animationComponent/index.es.js +204 -191
  10. package/dist/animationComponent/index.umd.js +3 -3
  11. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  12. package/dist/canvasAbsoluteMode/index.es.js +183 -170
  13. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  14. package/dist/canvasEmptyState/index.cjs.js +1 -1
  15. package/dist/canvasEmptyState/index.es.js +134 -121
  16. package/dist/canvasEmptyState/index.umd.js +1 -1
  17. package/dist/canvasFullSize/index.cjs.js +9 -9
  18. package/dist/canvasFullSize/index.es.js +165 -152
  19. package/dist/canvasFullSize/index.umd.js +9 -9
  20. package/dist/canvasGridMode/index.cjs.js +5 -5
  21. package/dist/canvasGridMode/index.es.js +245 -232
  22. package/dist/canvasGridMode/index.umd.js +4 -4
  23. package/dist/canvasScreenshot/index.cjs.js +1 -1
  24. package/dist/canvasScreenshot/index.es.js +155 -142
  25. package/dist/canvasScreenshot/index.umd.js +1 -1
  26. package/dist/dataSourceEjs/index.cjs.js +9 -9
  27. package/dist/dataSourceEjs/index.es.js +257 -244
  28. package/dist/dataSourceEjs/index.umd.js +9 -9
  29. package/dist/dataSourceHandlebars/index.cjs.js +8 -8
  30. package/dist/dataSourceHandlebars/index.es.js +216 -203
  31. package/dist/dataSourceHandlebars/index.umd.js +7 -7
  32. package/dist/dialogComponent/index.cjs.js +14 -14
  33. package/dist/dialogComponent/index.es.js +141 -128
  34. package/dist/dialogComponent/index.umd.js +14 -14
  35. package/dist/flexComponent/index.cjs.js +13 -13
  36. package/dist/flexComponent/index.es.js +484 -471
  37. package/dist/flexComponent/index.umd.js +13 -13
  38. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  39. package/dist/fsLightboxComponent/index.es.js +173 -160
  40. package/dist/fsLightboxComponent/index.umd.js +3 -3
  41. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  42. package/dist/googleFontsAssetProvider/index.es.js +160 -147
  43. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  44. package/dist/iconifyComponent/index.cjs.js +2 -2
  45. package/dist/iconifyComponent/index.es.js +196 -183
  46. package/dist/iconifyComponent/index.umd.js +2 -2
  47. package/dist/index.cjs.js +25 -25
  48. package/dist/index.es.js +121 -108
  49. package/dist/index.umd.js +18 -18
  50. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  51. package/dist/layoutSidebarButtons/index.es.js +157 -144
  52. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  53. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  54. package/dist/lightGalleryComponent/index.es.js +245 -232
  55. package/dist/lightGalleryComponent/index.umd.js +1 -1
  56. package/dist/linkImageComponent/index.cjs.js +2 -2
  57. package/dist/linkImageComponent/index.es.js +106 -93
  58. package/dist/linkImageComponent/index.umd.js +2 -2
  59. package/dist/listPagesComponent/index.cjs.js +5 -5
  60. package/dist/listPagesComponent/index.es.js +157 -144
  61. package/dist/listPagesComponent/index.umd.js +5 -5
  62. package/dist/presetPrintable/index.cjs.js +3 -3
  63. package/dist/presetPrintable/index.es.js +181 -168
  64. package/dist/presetPrintable/index.umd.js +3 -3
  65. package/dist/prosemirror/index.cjs.js +7 -7
  66. package/dist/prosemirror/index.es.js +385 -372
  67. package/dist/prosemirror/index.umd.js +8 -8
  68. package/dist/rendererReact/index.cjs.js +1 -1
  69. package/dist/rendererReact/index.es.js +200 -187
  70. package/dist/rendererReact/index.js +1 -1
  71. package/dist/rendererReact/index.umd.js +1 -1
  72. package/dist/rteTinyMce/index.cjs.js +2 -2
  73. package/dist/rteTinyMce/index.es.js +118 -105
  74. package/dist/rteTinyMce/index.umd.js +2 -2
  75. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  76. package/dist/shapeDividerComponent/index.es.js +129 -116
  77. package/dist/shapeDividerComponent/index.umd.js +4 -4
  78. package/dist/swiperComponent/index.cjs.js +9 -9
  79. package/dist/swiperComponent/index.es.js +203 -190
  80. package/dist/swiperComponent/index.umd.js +7 -7
  81. package/dist/tableComponent/index.cjs.js +1 -1
  82. package/dist/tableComponent/index.es.js +257 -244
  83. package/dist/tableComponent/index.umd.js +1 -1
  84. package/dist/types.d.ts +1 -1
  85. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  86. package/dist/youtubeAssetProvider/index.es.js +121 -108
  87. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  88. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";const y=require("react/jsx-runtime"),h=require("react"),W=require("react-dom/client"),D="app.grapesjs.com",_="app-stage.grapesjs.com",$="app2.grapesjs.com",B="app-stage2.grapesjs.com",R=[D,$,_,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:start",F="license:check:end",K=()=>typeof window<"u",M=({isDev:e,isStage:t,isPlatform:n})=>`${e?"":`https://${t?_:D}`}/${n?"platform-api":"api"}`,V=()=>{const e=K()&&window.location.hostname;return!!e&&(R.includes(e)||R.some(t=>e.endsWith(t)))},z=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,n)=>(n?"-":"")+t.toLowerCase()),T=e=>typeof e=="string";function q(e){return typeof e=="function"}async function G({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:r,body:o}){const c=`${t||M({isDev:!1,isStage:!1})}${e}`,i={method:n,headers:{"Content-Type":"application/json",...s}};o&&(i.body=JSON.stringify(o));const u=r?new URLSearchParams(r).toString():"",d=u?`?${u}`:"",p=await fetch(`${c}${d}`,i);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var v=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(v||{});const P={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function J(e){const t=e;return t.init=n=>s=>e(s,n),t}const H=e=>J(e);async function Z({editor:e,plan:t,pluginName:n,licenseKey:s,onLicenseCheckResponse:r,cleanup:o}){let a="",c=!1;const i=V(),u=p=>{console.warn("Cleanup plugin:",n,"Reason:",p),o()},d=(p={})=>{var b;const{error:m,sdkLicense:f}=p,l=(b=p.plan)==null?void 0:b.category;if(!(f||p.license)||m)u(m||"Invalid license");else if(l){const C=P[t],A=P[l];C>A&&u({pluginRequiredPlan:t,licensePlan:l})}};e.on(L,p=>{a=p==null?void 0:p.baseApiUrl,c=!0}),e.on(F,p=>{r==null||r(p),d(p)}),setTimeout(async()=>{if(!c){if(i)return;if(s){const p=await Q({licenseKey:s,pluginName:n,baseApiUrl:a});r==null||r(p),p&&d(p)}else u("The `licenseKey` option not provided")}},2e3)}async function Q(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await G({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}function X(e){const t={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=z(n);t[s]=e[n]}return t}const Y=(e,t)=>{const n=e.components||{};for(const s in n){const r=n[s];if(r.component===t)return{cmpConfig:r,type:s}}};function O(e){const t={};let n=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(typeof r=="string"||typeof r=="number"){const o=s.includes("-")?s.replace(/-([a-z])/g,a=>a[1].toUpperCase()):s;t[o]=r,n=!0}}return n?t:void 0}function ee(e){const t={};return e.split(";").forEach(n=>{if(!n.trim())return;const s=n.indexOf(":");if(s>0){const r=n.substring(0,s).trim(),o=n.substring(s+1).trim();if(r&&o){const a=r.replace(/-([a-z])/g,c=>c[1].toUpperCase());t[a]=o}}}),Object.keys(t).length>0?t:void 0}function te(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return O(e);if(typeof e=="string"){let t=ee(e);if(!t)try{const n=JSON.parse(e);typeof n=="object"&&n!==null&&!Array.isArray(n)&&(t=O(n))}catch(n){console.error("Failed to parse style string as JSON",n)}return t}if(Array.isArray(e)){const t={};return e.forEach(n=>{if(typeof n=="object"&&n!==null){const s=n.name||n.property,r=n.value;if(typeof s=="string"&&s&&r!==void 0&&r!==""){const o=s.replace(/-([a-z])/g,a=>a[1].toUpperCase());t[o]=r}}}),Object.keys(t).length>0?t:void 0}}}function ne(e){return j[e]?j[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase()):e}function oe(e){var n;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=te(r);else if(s.startsWith("data-"))t[s]=r;else{const o=ne(s);((n=e.xmlns)==null?void 0:n.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||re.has(o)||o.startsWith("svg")?t[o]=r:!se.has(o)&&!o.startsWith("on")&&!o.startsWith("aria-")&&!o.startsWith("data-")?t[s]=r:t[o]=r}return t}const se=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),re=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),j={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},S=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ce(e){return t=>{const n=t.getContent();S(n)&&t.set({content:E({...e,model:n}),reactContent:n})}}const ae=e=>t=>{const n=t.component;S(n)&&(t.component={components:E({...e,model:n})})};function E(e){const{model:t,editor:n,config:s}=e;if(S(t)){const r=t,o={},{type:a,props:c={}}=r,{children:i,className:u,style:d,...p}=c,m=l=>({type:"textnode",content:l}),f=typeof a=="symbol";if(q(a)){const l=Y(s,a);o.type=l==null?void 0:l.type}else n.Components.getType(a)?o.type=a:f||(o.tagName=a);if(u&&(o.classes=u),d&&(o.style=X(d)),Array.isArray(i)?o.components=i.map(l=>T(l)?m(l):E({...e,model:l})).filter(Boolean):T(i)&&(o.components=m(i)),Object.keys(p).length){const l=n.Parser.parserHtml.splitPropsFromAttr(p);o.attributes=l.attrs,Object.assign(o,l.props)}return o}}function ie(e){const{component:t}=e,[n,s]=h.useState(0),[r,o]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const c=()=>s(l=>l+1),i=()=>{[...t.views].forEach(w=>w.remove()),o(void 0)},{em:u}=t,d=u.Components.events,m=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(m,c),t.on(f,i),()=>{t.off(m,c),t.off(f,i),i()}},[t]),{key:n,view:r,connectDom:c=>{if(!c)return;const i=le({...e,el:c});o(i)}}}function le(e){var i;const{editor:t,component:n,el:s,frameView:r}=e,{em:o,Components:a}=t;let c=n.getView(r.model);if((c==null?void 0:c.el)===s)return c;if(!c){const{ComponentView:u}=a,d=n.attributes.type||"default",p=((i=a.getType(d))==null?void 0:i.view)||u,m={...a.config,frameView:r,em:o},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});c=new f({el:s,config:m,model:n})}return c.el=s,c.render(),c}function pe(e,t){const{Components:n}=e,s=r=>{const{id:o,model:a}=r;n.addType(o,{model:{toJSON(...c){const i=a.prototype.toJSON.apply(this,c);return i.tagName=this.tagName,i}}})};n.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([r,o])=>{var m,f;const{allowPropClassName:a,allowPropId:c,allowChildren:i}=o,u=!c&&!a,d=()=>({disabled:u}),p=()=>({disableClasses:!a,disableComponent:!c});n.addType(r,{isComponent:l=>(l==null?void 0:l.tagName)===r,model:{defaults:{type:r,traits:((m=o.props)==null?void 0:m.call(o))||[],droppable:!!i,stylable:!u,styleManager:d,selectorManager:p,...((f=o.model)==null?void 0:f.defaults)||{}}}})})}function I(e){var N;const{component:t,config:n,editor:s,frameView:r,onMount:o,tagName:a,children:c}=e,{key:i,view:u,connectDom:d}=ie(e);h.useEffect(()=>{if(!u&&!o)return;const g=setTimeout(()=>{u&&(o==null||o(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(g)},[u]);const p=t.get("type")||"default",m=t.content,f=(N=n.components)==null?void 0:N[p],l=(f==null?void 0:f.component)||a||t.tagName||"div",w=t.components(),b=w.length?w.map(g=>y.jsx(I,{component:g,config:n,editor:s,frameView:r},g.cid)):[m||void 0],C=oe(t.getAttributes()),A=f==null?void 0:f.editorRender,x=[...b,c].filter(g=>g??!1),k=x.length?x:null;if(A)return y.jsx(A,{props:C,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...C,children:k})});if(t.isInstanceOf("textnode"))return m;const U=t.isInstanceOf("text")?i:void 0;return h.createElement(l,{...C,ref:d,key:U},t.get("void")?null:k)}const ue=e=>{const{frame:t,window:n,onMount:s,editor:r}=e,o=r.Canvas.events,{root:a}=t;try{const c=W.createRoot(n.document.body);c.render(y.jsx(fe,{...e,component:a,onMount:s}));const i=()=>c.unmount();t.once(o.frameUnload,i),n.addEventListener("unload",i)}catch(c){console.warn(c)}return a.getView()};function fe(e){const{editor:t,component:n,window:s,frameView:r,config:o,onMount:a}=e,c=s.document,i=o.rootComponent||h.Fragment,u=o.rootComponent?{editorProps:{doc:c,editor:t,frameView:r}}:{},d=(o==null?void 0:o.bodyAfter)||h.Fragment;return y.jsx(i,{...u,children:y.jsx(I,{tagName:"div",component:n,config:o,editor:t,frameView:r,onMount:a,children:y.jsx(d,{...u})})})}const de="rendererReact",me=v.startup,ye=function(e,t={}){const{Blocks:n,Pages:s}=e,r=n.events,o=s.events;e.Canvas.config.customRenderer=c=>ue({...c,config:t}),e.Components.config.processor=c=>E({model:c,editor:e,config:t}),pe(e,t);const a=[[r.add,ce({editor:e,config:t})],[o.addBefore,ae({editor:e,config:t})]];a.forEach(([c,i])=>e.on(c,i)),Z({editor:e,licenseKey:t.licenseKey,plan:me,pluginName:de,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,a.forEach(([c,i])=>e.off(c,i))}})},he=H(ye);module.exports=he;
1
+ "use strict";const y=require("react/jsx-runtime"),h=require("react"),M=require("react-dom/client"),C="app.grapesjs.com",G="app-stage.grapesjs.com",_="app2.grapesjs.com",F="app-stage2.grapesjs.com",D=[C,_,G,F,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],W="license:check:end",$=()=>typeof window<"u",S=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:C}`}/${o?"platform-api":"api"}`,K=()=>{const e=$()&&window.location.hostname;return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},V=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function z(e){return typeof e=="function"}async function q({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:r,body:n}){const a=`${t||S({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=r?new URLSearchParams(r).toString():"",d=u?`?${u}`:"",p=await fetch(`${a}${d}`,c);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),x=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(x||{});const L={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function J(e){const t=e;return t.init=o=>s=>e(s,o),t}const H=e=>J(e);async function Z({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:r,cleanup:n}){let i="",a;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n()},u=(p={})=>{var w;const{error:g,sdkLicense:f}=p,l=(w=p.plan)==null?void 0:w.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const R=L[t],A=L[l];R>A&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(x.settings)&&(a=e.runCommand(x.settings),i=(a==null?void 0:a.baseUrl)||"");const d=p=>{r==null||r(p),p&&u(p)};if(!a){e.onReady(async()=>{if(!K())if(s){const p=await X({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const p=Q(a);d(p);return}e.on(W,p=>d(p))}const Q=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function X(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await q({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}function Y(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=V(o);t[s]=e[o]}return t}const ee=(e,t)=>{const o=e.components||{};for(const s in o){const r=o[s];if(r.component===t)return{cmpConfig:r,type:s}}};function j(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(typeof r=="string"||typeof r=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=r,o=!0}}return o?t:void 0}function te(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const r=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(r&&n){const i=r.replace(/-([a-z])/g,a=>a[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function oe(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=te(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=j(o))}catch(o){console.error("Failed to parse style string as JSON",o)}return t}if(Array.isArray(e)){const t={};return e.forEach(o=>{if(typeof o=="object"&&o!==null){const s=o.name||o.property,r=o.value;if(typeof s=="string"&&s&&r!==void 0&&r!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=r}}}),Object.keys(t).length>0?t:void 0}}}function ne(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function se(e){var o;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=oe(r);else if(s.startsWith("data-"))t[s]=r;else{const n=ne(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ae.has(n)||n.startsWith("svg")?t[n]=r:!re.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=r:t[n]=r}return t}const re=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),ae=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),B={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},T=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ie(e){return t=>{const o=t.getContent();T(o)&&t.set({content:P({...e,model:o}),reactContent:o})}}const ce=e=>t=>{const o=t.component;T(o)&&(t.component={components:P({...e,model:o})})};function P(e){const{model:t,editor:o,config:s}=e;if(T(t)){const r=t,n={},{type:i,props:a={}}=r,{children:c,className:u,style:d,...p}=a,g=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(z(i)){const l=ee(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:f||(n.tagName=i);if(u&&(n.classes=u),d&&(n.style=Y(d)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):P({...e,model:l})).filter(Boolean):N(c)&&(n.components=g(c)),Object.keys(p).length){const l=o.Parser.parserHtml.splitPropsFromAttr(p);n.attributes=l.attrs,Object.assign(n,l.props)}return n}}function le(e){const{component:t}=e,[o,s]=h.useState(0),[r,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const a=()=>s(l=>l+1),c=()=>{[...t.views].forEach(m=>m.remove()),n(void 0)},{em:u}=t,d=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(g,a),t.on(f,c),()=>{t.off(g,a),t.off(f,c),c()}},[t]),{key:o,view:r,connectDom:a=>{if(!a)return;const c=pe({...e,el:a});n(c)}}}function pe(e){var c;const{editor:t,component:o,el:s,frameView:r}=e,{em:n,Components:i}=t;let a=o.getView(r.model);if((a==null?void 0:a.el)===s)return a;if(!a){const{ComponentView:u}=i,d=o.attributes.type||"default",p=((c=i.getType(d))==null?void 0:c.view)||u,g={...i.config,frameView:r,em:n},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});a=new f({el:s,config:g,model:o})}return a.el=s,a.render(),a}function ue(e,t){const{Components:o}=e,s=r=>{const{id:n,model:i}=r;o.addType(n,{model:{toJSON(...a){const c=i.prototype.toJSON.apply(this,a);return c.tagName=this.tagName,c}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([r,n])=>{var g,f;const{allowPropClassName:i,allowPropId:a,allowChildren:c}=n,u=!a&&!i,d=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!a});o.addType(r,{isComponent:l=>(l==null?void 0:l.tagName)===r,model:{defaults:{type:r,traits:((g=n.props)==null?void 0:g.call(n))||[],droppable:!!c,stylable:!u,styleManager:d,selectorManager:p,...((f=n.model)==null?void 0:f.defaults)||{}}}})})}function I(e){var O;const{component:t,config:o,editor:s,frameView:r,onMount:n,tagName:i,children:a}=e,{key:c,view:u,connectDom:d}=le(e);h.useEffect(()=>{if(!u&&!n)return;const v=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const p=t.get("type")||"default",g=t.content,f=(O=o.components)==null?void 0:O[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",m=t.components(),w=m.length?m.map(v=>y.jsx(I,{component:v,config:o,editor:s,frameView:r},v.cid)):[g||void 0],R=se(t.getAttributes()),A=f==null?void 0:f.editorRender,E=[...w,a].filter(v=>v??!1),k=E.length?E:null;if(A)return y.jsx(A,{props:R,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...R,children:k})});if(t.isInstanceOf("textnode"))return g;const U=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...R,ref:d,key:U},t.get("void")?null:k)}const fe=e=>{const{frame:t,window:o,onMount:s,editor:r}=e,n=r.Canvas.events,{root:i}=t;try{const a=M.createRoot(o.document.body);a.render(y.jsx(de,{...e,component:i,onMount:s}));const c=()=>a.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(a){console.warn(a)}return i.getView()};function de(e){const{editor:t,component:o,window:s,frameView:r,config:n,onMount:i}=e,a=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:a,editor:t,frameView:r}}:{},d=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(I,{tagName:"div",component:o,config:n,editor:t,frameView:r,onMount:i,children:y.jsx(d,{...u})})})}const ge="rendererReact",ye=b.startup,he=function(e,t={}){const{Blocks:o,Pages:s}=e,r=o.events,n=s.events;e.Canvas.config.customRenderer=a=>fe({...a,config:t}),e.Components.config.processor=a=>P({model:a,editor:e,config:t}),ue(e,t);const i=[[r.add,ie({editor:e,config:t})],[n.addBefore,ce({editor:e,config:t})]];i.forEach(([a,c])=>e.on(a,c)),Z({editor:e,licenseKey:t.licenseKey,plan:ye,pluginName:ge,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([a,c])=>e.off(a,c))}})},ve=H(he);module.exports=ve;
@@ -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,j){"use strict";const N="app.grapesjs.com",T="app-stage.grapesjs.com",x=[N,"app2.grapesjs.com",T,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],W="license:check:start",M="license:check:end",$=()=>typeof window<"u",B=({isDev:e,isStage:t,isPlatform:n})=>`${e?"":`https://${t?T:N}`}/${n?"platform-api":"api"}`,L=()=>{const e=$()&&window.location.hostname;return!!e&&(x.includes(e)||x.some(t=>e.endsWith(t)))},F=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,n)=>(n?"-":"")+t.toLowerCase()),O=e=>typeof e=="string";function K(e){return typeof e=="function"}async function V({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:r,body:o}){const c=`${t||B({isDev:!1,isStage:!1})}${e}`,a={method:n,headers:{"Content-Type":"application/json",...s}};o&&(a.body=JSON.stringify(o));const d=r?new URLSearchParams(r).toString():"",u=d?`?${d}`:"",p=await fetch(`${c}${u}`,a);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{});const P={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function z(e){const t=e;return t.init=n=>s=>e(s,n),t}const q=e=>z(e);async function G({editor:e,plan:t,pluginName:n,licenseKey:s,onLicenseCheckResponse:r,cleanup:o}){let i="",c=!1;const a=L(),d=p=>{console.warn("Cleanup plugin:",n,"Reason:",p),o()},u=(p={})=>{var A;const{error:m,sdkLicense:f}=p,l=(A=p.plan)==null?void 0:A.category;if(!(f||p.license)||m)d(m||"Invalid license");else if(l){const C=P[t],E=P[l];C>E&&d({pluginRequiredPlan:t,licensePlan:l})}};e.on(W,p=>{i=p==null?void 0:p.baseApiUrl,c=!0}),e.on(M,p=>{r==null||r(p),u(p)}),setTimeout(async()=>{if(!c){if(a)return;if(s){const p=await J({licenseKey:s,pluginName:n,baseApiUrl:i});r==null||r(p),p&&u(p)}else d("The `licenseKey` option not provided")}},2e3)}async function J(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await V({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}function H(e){const t={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=F(n);t[s]=e[n]}return t}const Z=(e,t)=>{const n=e.components||{};for(const s in n){const r=n[s];if(r.component===t)return{cmpConfig:r,type:s}}};function R(e){const t={};let n=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(typeof r=="string"||typeof r=="number"){const o=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[o]=r,n=!0}}return n?t:void 0}function Q(e){const t={};return e.split(";").forEach(n=>{if(!n.trim())return;const s=n.indexOf(":");if(s>0){const r=n.substring(0,s).trim(),o=n.substring(s+1).trim();if(r&&o){const i=r.replace(/-([a-z])/g,c=>c[1].toUpperCase());t[i]=o}}}),Object.keys(t).length>0?t:void 0}function X(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return R(e);if(typeof e=="string"){let t=Q(e);if(!t)try{const n=JSON.parse(e);typeof n=="object"&&n!==null&&!Array.isArray(n)&&(t=R(n))}catch(n){console.error("Failed to parse style string as JSON",n)}return t}if(Array.isArray(e)){const t={};return e.forEach(n=>{if(typeof n=="object"&&n!==null){const s=n.name||n.property,r=n.value;if(typeof s=="string"&&s&&r!==void 0&&r!==""){const o=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[o]=r}}}),Object.keys(t).length>0?t:void 0}}}function Y(e){return D[e]?D[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase()):e}function ee(e){var n;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=X(r);else if(s.startsWith("data-"))t[s]=r;else{const o=Y(s);((n=e.xmlns)==null?void 0:n.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ne.has(o)||o.startsWith("svg")?t[o]=r:!te.has(o)&&!o.startsWith("on")&&!o.startsWith("aria-")&&!o.startsWith("data-")?t[s]=r:t[o]=r}return t}const te=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"]),D={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},S=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function oe(e){return t=>{const n=t.getContent();S(n)&&t.set({content:b({...e,model:n}),reactContent:n})}}const se=e=>t=>{const n=t.component;S(n)&&(t.component={components:b({...e,model:n})})};function b(e){const{model:t,editor:n,config:s}=e;if(S(t)){const r=t,o={},{type:i,props:c={}}=r,{children:a,className:d,style:u,...p}=c,m=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(K(i)){const l=Z(s,i);o.type=l==null?void 0:l.type}else n.Components.getType(i)?o.type=i:f||(o.tagName=i);if(d&&(o.classes=d),u&&(o.style=H(u)),Array.isArray(a)?o.components=a.map(l=>O(l)?m(l):b({...e,model:l})).filter(Boolean):O(a)&&(o.components=m(a)),Object.keys(p).length){const l=n.Parser.parserHtml.splitPropsFromAttr(p);o.attributes=l.attrs,Object.assign(o,l.props)}return o}}function re(e){const{component:t}=e,[n,s]=h.useState(0),[r,o]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const c=()=>s(l=>l+1),a=()=>{[...t.views].forEach(w=>w.remove()),o(void 0)},{em:d}=t,u=d.Components.events,m=[...["components","attributes","classes"].map(l=>`${u.update}:${l}`),"rerender"].join(" "),f=[u.removed,"rerender"].join(" ");return t.on(m,c),t.on(f,a),()=>{t.off(m,c),t.off(f,a),a()}},[t]),{key:n,view:r,connectDom:c=>{if(!c)return;const a=ce({...e,el:c});o(a)}}}function ce(e){var a;const{editor:t,component:n,el:s,frameView:r}=e,{em:o,Components:i}=t;let c=n.getView(r.model);if((c==null?void 0:c.el)===s)return c;if(!c){const{ComponentView:d}=i,u=n.attributes.type||"default",p=((a=i.getType(u))==null?void 0:a.view)||d,m={...i.config,frameView:r,em:o},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});c=new f({el:s,config:m,model:n})}return c.el=s,c.render(),c}function ie(e,t){const{Components:n}=e,s=r=>{const{id:o,model:i}=r;n.addType(o,{model:{toJSON(...c){const a=i.prototype.toJSON.apply(this,c);return a.tagName=this.tagName,a}}})};n.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([r,o])=>{var m,f;const{allowPropClassName:i,allowPropId:c,allowChildren:a}=o,d=!c&&!i,u=()=>({disabled:d}),p=()=>({disableClasses:!i,disableComponent:!c});n.addType(r,{isComponent:l=>(l==null?void 0:l.tagName)===r,model:{defaults:{type:r,traits:((m=o.props)==null?void 0:m.call(o))||[],droppable:!!a,stylable:!d,styleManager:u,selectorManager:p,...((f=o.model)==null?void 0:f.defaults)||{}}}})})}function _(e){var U;const{component:t,config:n,editor:s,frameView:r,onMount:o,tagName:i,children:c}=e,{key:a,view:d,connectDom:u}=re(e);h.useEffect(()=>{if(!d&&!o)return;const v=setTimeout(()=>{d&&(o==null||o(d),setTimeout(()=>d.postRender()))});return()=>clearTimeout(v)},[d]);const p=t.get("type")||"default",m=t.content,f=(U=n.components)==null?void 0:U[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",w=t.components(),A=w.length?w.map(v=>y.jsx(_,{component:v,config:n,editor:s,frameView:r},v.cid)):[m||void 0],C=ee(t.getAttributes()),E=f==null?void 0:f.editorRender,I=[...A,c].filter(v=>v??!1),k=I.length?I:null;if(E)return y.jsx(E,{props:C,editor:s,component:t,connectDom:u,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:u,style:f.wrapperStyle,children:y.jsx(l,{...C,children:k})});if(t.isInstanceOf("textnode"))return m;const fe=t.isInstanceOf("text")?a:void 0;return h.createElement(l,{...C,ref:u,key:fe},t.get("void")?null:k)}const ae=e=>{const{frame:t,window:n,onMount:s,editor:r}=e,o=r.Canvas.events,{root:i}=t;try{const c=j.createRoot(n.document.body);c.render(y.jsx(le,{...e,component:i,onMount:s}));const a=()=>c.unmount();t.once(o.frameUnload,a),n.addEventListener("unload",a)}catch(c){console.warn(c)}return i.getView()};function le(e){const{editor:t,component:n,window:s,frameView:r,config:o,onMount:i}=e,c=s.document,a=o.rootComponent||h.Fragment,d=o.rootComponent?{editorProps:{doc:c,editor:t,frameView:r}}:{},u=(o==null?void 0:o.bodyAfter)||h.Fragment;return y.jsx(a,{...d,children:y.jsx(_,{tagName:"div",component:n,config:o,editor:t,frameView:r,onMount:i,children:y.jsx(u,{...d})})})}const pe="rendererReact",de=g.startup;return q(function(e,t={}){const{Blocks:n,Pages:s}=e,r=n.events,o=s.events;e.Canvas.config.customRenderer=c=>ae({...c,config:t}),e.Components.config.processor=c=>b({model:c,editor:e,config:t}),ie(e,t);const i=[[r.add,oe({editor:e,config:t})],[o.addBefore,se({editor:e,config:t})]];i.forEach(([c,a])=>e.on(c,a)),G({editor:e,licenseKey:t.licenseKey,plan:de,pluginName:pe,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([c,a])=>e.off(c,a))}})})});
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,4 +1,4 @@
1
- "use strict";var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{}),m=(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.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))(m||{}),I=(t=>(t.dark="dark",t.light="light",t.auto="auto",t))(I||{});const O="app.grapesjs.com",L="app-stage.grapesjs.com",M="app2.grapesjs.com",N="app-stage2.grapesjs.com",R=[O,M,L,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",U="license:check:end",j=()=>typeof window<"u",W=({isDev:t,isStage:s,isPlatform:n})=>`${t?"":`https://${s?L:O}`}/${n?"platform-api":"api"}`,$=()=>{const t=j()&&window.location.hostname;return!!t&&(R.includes(t)||R.some(s=>t.endsWith(s)))};async function F({path:t,baseApiUrl:s,method:n="GET",headers:a={},params:r,body:c}){const l=`${s||W({isDev:!1,isStage:!1})}${t}`,i={method:n,headers:{"Content-Type":"application/json",...a}};c&&(i.body=JSON.stringify(c));const u=r?new URLSearchParams(r).toString():"",e=u?`?${u}`:"",o=await fetch(`${l}${e}`,i);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}const k={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function K(t){const s=t;return s.init=n=>a=>t(a,n),s}const S=t=>K(t);async function q({editor:t,plan:s,pluginName:n,licenseKey:a,onLicenseCheckResponse:r,cleanup:c}){let d="",l=!1;const i=$(),u=o=>{console.warn("Cleanup plugin:",n,"Reason:",o),c()},e=(o={})=>{var w;const{error:b,sdkLicense:x}=o,g=(w=o.plan)==null?void 0:w.category;if(!(x||o.license)||b)u(b||"Invalid license");else if(g){const p=k[s],P=k[g];p>P&&u({pluginRequiredPlan:s,licensePlan:g})}};t.on(B,o=>{d=o==null?void 0:o.baseApiUrl,l=!0}),t.on(U,o=>{r==null||r(o),e(o)}),setTimeout(async()=>{if(!l){if(i)return;if(a){const o=await H({licenseKey:a,pluginName:n,baseApiUrl:d});r==null||r(o),o&&e(o)}else u("The `licenseKey` option not provided")}},2e3)}async function H(t){const{licenseKey:s,pluginName:n,baseApiUrl:a}=t;try{return(await F({baseApiUrl:a,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}const C=(t,s,n)=>{const{doc:a=document}=n,r=n.target||a.head,c=r.querySelector(`style[${t}]`)||a.createElement("style");c.setAttribute(t,"true"),c.innerHTML=s,!r.contains(c)&&r.appendChild(c)},z=t=>t.dispatchEvent(new CustomEvent("input"));function V(t,s){if(!s)return()=>{};const n=t.Components.events,a=e=>t.getSelectedAll().includes(e),r=e=>e.isInstanceOf("text")&&!e.isChildOf("text"),c=e=>e.isChildOf("text"),d=e=>t.getEditing()===e,l=(e,o={})=>{e.trigger("focus",o.event)},i=(e,o)=>{a(e)&&r(e)&&!d(e)&&l(e,o)},u=(e,o)=>{if(a(e)&&!r(e)&&c(e)){const b=e.parents().find(x=>x.isInstanceOf("text"));b&&(l(b,o),setTimeout(()=>t.select(b),0))}};return t.on(n.select,i),t.on(n.selectBefore,u),()=>{t.off(n.select,i),t.off(n.selectBefore,u)}}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.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=`
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),y=t=>{const s=t.target,n=s.closest(".tox"),a=s.matches(".ephox-snooker-resizer-bar");(n||a)&&t.stopPropagation()},D=t=>{t.stopPropagation(),t.preventDefault()},tt=(t,s)=>{const n=t.getDoc(),a=t.getWin();if(s!=null&&s.event){const{event:r}=s,{clientX:c,clientY:d}=r;let l;if(n.caretRangeFromPoint)l=n.caretRangeFromPoint(c,d);else if(n.caretPositionFromPoint){const i=n.caretPositionFromPoint(c,d);l=n.createRange(),l==null||l.setStart(i.offsetNode,i.offset)}if(l){const i=a.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(l),t.selection.setRng(l)}}else t.execCommand("SelectAll")},et=t=>{var u,e;const{el:s,editor:n,componentView:a}=t,r=n.runCommand(m.getStateTheme),c=a.model,d={target:s,inline:!0,skin:(r==null?void 0:r.theme)===I.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"},l=((e=(u=t.pluginOpts)==null?void 0:u.loadConfig)==null?void 0:e.call(u,{config:d,editor:n,componentView:a,component:c}))||{};return{...d,...l}},A=(t,s=document)=>new Promise((n,a)=>{const r=Array.isArray(t)?[...t]:[t],{head:c}=s,d=l=>{if(l.length){const i=s.createElement("script");i.src=l.shift(),i.onload=d.bind(null,l),i.onerror=a,c.appendChild(i)}else n()};d(r)}),ot=function(t,s={}){const n={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...s},{cdnScript:a}=n,r=t.Canvas.events,c=!n.skipCustomTheme,d="gs-plg-tinymce-studio-theme",l=async(e,o)=>{const b=e.ownerDocument,x=b.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(),b.body.addEventListener("mousedown",y),document.body.addEventListener("mousedown",y),p.on("Change",()=>z(e)),p.on("blur",()=>p.ui.show()),p.on("OpenWindow",function(){var _;const f=(_=b.querySelector(".tox-dialog"))==null?void 0:_.closest(".tox");f&&(f==null?void 0:f.ownerDocument)!==document&&(document.body.appendChild(f),p.once("CloseWindow",()=>{f&&f.ownerDocument===document&&b.body.appendChild(f)}))}),e.addEventListener("dragstart",D,{capture:!0}),t.runCommand(m.setStateContextMenu,{enabled:!1}),tt(p,o),{rteEditor:p,rteEditorShallow:G}},i=(e,o)=>{e.ownerDocument.body.removeEventListener("mousedown",y),document.body.removeEventListener("mousedown",y),e.removeEventListener("dragstart",D,{capture:!0}),t.runCommand(m.setStateContextMenu,{enabled:!0}),o.rteEditor.destroy(),o.rteEditorShallow.destroy()};t.on(r.frameLoad,async({window:e})=>{const o=e.document;A(a,o)}),t.onReady(()=>{A(a,document),c&&C(d,Y,{target:document.body})}),t.setCustomRte({parseContent:!0,async enable(e,o,b){const x=T(e);if(x)return x.rteEditor;const g=await l(e,b);return g&&Q(e,g),g==null?void 0:g.rteEditor},disable(e){const o=T(e);o&&(Z(e),i(e,o))},getContent(e,o,b){var h;const x=T(e),g=x==null?void 0:x.rteEditor;return g&&!g.isDirty()?b.view.lastContent:g?(h=g.getContent)==null?void 0:h.call(g):e.innerHTML}});const u=V(t,n.enableOnClick);q({editor:t,licenseKey:n.licenseKey,plan:X,pluginName:J,cleanup:()=>{t.RichTextEditor.customRte=void 0,u()}})},nt=S(ot);module.exports=nt;
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;
@@ -1,9 +1,9 @@
1
- var v = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(v || {}), m = /* @__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.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))(m || {}), I = /* @__PURE__ */ ((t) => (t.dark = "dark", t.light = "light", t.auto = "auto", t))(I || {});
2
- const O = "app.grapesjs.com", L = "app-stage.grapesjs.com", M = "app2.grapesjs.com", N = "app-stage2.grapesjs.com", R = [
3
- O,
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 || {});
2
+ const I = "app.grapesjs.com", O = "app-stage.grapesjs.com", M = "app2.grapesjs.com", B = "app-stage2.grapesjs.com", k = [
3
+ I,
4
4
  M,
5
- L,
6
- N,
5
+ O,
6
+ B,
7
7
  "localhost",
8
8
  "127.0.0.1",
9
9
  ".local-credentialless.webcontainer.io",
@@ -12,87 +12,100 @@ const O = "app.grapesjs.com", L = "app-stage.grapesjs.com", M = "app2.grapesjs.c
12
12
  // For stackblitz.com demos
13
13
  "-sandpack.codesandbox.io"
14
14
  // For Sandpack demos
15
- ], B = "license:check:start", U = "license:check:end", j = () => typeof window < "u", W = ({
15
+ ], N = "license:check:end", U = () => typeof window < "u", j = ({
16
16
  isDev: t,
17
17
  isStage: s,
18
18
  isPlatform: n
19
- }) => `${t ? "" : `https://${s ? L : O}`}/${n ? "platform-api" : "api"}`, $ = () => {
20
- const t = j() && window.location.hostname;
21
- return !!t && (R.includes(t) || R.some((s) => t.endsWith(s)));
19
+ }) => `${t ? "" : `https://${s ? O : I}`}/${n ? "platform-api" : "api"}`, F = () => {
20
+ const t = U() && window.location.hostname;
21
+ return !!t && (k.includes(t) || k.some((s) => t.endsWith(s)));
22
22
  };
23
- async function F({
23
+ async function W({
24
24
  path: t,
25
25
  baseApiUrl: s,
26
26
  method: n = "GET",
27
- headers: a = {},
28
- params: r,
27
+ headers: i = {},
28
+ params: a,
29
29
  body: c
30
30
  }) {
31
- const l = `${s || W({ isDev: !1, isStage: !1 })}${t}`, i = {
31
+ const r = `${s || j({ isDev: !1, isStage: !1 })}${t}`, l = {
32
32
  method: n,
33
33
  headers: {
34
34
  "Content-Type": "application/json",
35
- ...a
35
+ ...i
36
36
  }
37
37
  };
38
- c && (i.body = JSON.stringify(c));
39
- const u = r ? new URLSearchParams(r).toString() : "", e = u ? `?${u}` : "", o = await fetch(`${l}${e}`, i);
38
+ c && (l.body = JSON.stringify(c));
39
+ const b = a ? new URLSearchParams(a).toString() : "", e = b ? `?${b}` : "", o = await fetch(`${r}${e}`, l);
40
40
  if (!o.ok)
41
41
  throw new Error(`HTTP error! status: ${o.status}`);
42
42
  return o.json();
43
43
  }
44
- const k = {
44
+ const _ = {
45
45
  [v.free]: 0,
46
46
  [v.startup]: 10,
47
47
  [v.business]: 20,
48
48
  [v.enterprise]: 30
49
49
  };
50
- function K(t) {
50
+ function $(t) {
51
51
  const s = t;
52
- return s.init = (n) => (a) => t(a, n), s;
52
+ return s.init = (n) => (i) => t(i, n), s;
53
53
  }
54
- const S = (t) => /* @__PURE__ */ K(t);
54
+ const C = (t) => /* @__PURE__ */ $(t);
55
55
  async function q({
56
56
  editor: t,
57
57
  plan: s,
58
58
  pluginName: n,
59
- licenseKey: a,
60
- onLicenseCheckResponse: r,
59
+ licenseKey: i,
60
+ onLicenseCheckResponse: a,
61
61
  cleanup: c
62
62
  }) {
63
- let d = "", l = !1;
64
- const i = $(), u = (o) => {
63
+ let d = "", r;
64
+ const l = (o) => {
65
65
  console.warn("Cleanup plugin:", n, "Reason:", o), c();
66
- }, e = (o = {}) => {
66
+ }, b = (o = {}) => {
67
67
  var w;
68
- const { error: b, sdkLicense: x } = o, g = (w = o.plan) == null ? void 0 : w.category;
69
- if (!(x || o.license) || b)
70
- u(b || "Invalid license");
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");
71
71
  else if (g) {
72
- const p = k[s], P = k[g];
73
- p > P && u({ pluginRequiredPlan: s, licensePlan: g });
72
+ const p = _[s], R = _[g];
73
+ p > R && l({ pluginRequiredPlan: s, licensePlan: g });
74
74
  }
75
75
  };
76
- t.on(B, (o) => {
77
- d = o == null ? void 0 : o.baseApiUrl, l = !0;
78
- }), t.on(U, (o) => {
79
- r == null || r(o), e(o);
80
- }), setTimeout(async () => {
81
- if (!l) {
82
- if (i) return;
83
- if (a) {
84
- const o = await H({ licenseKey: a, pluginName: n, baseApiUrl: d });
85
- r == null || r(o), o && e(o);
86
- } else
87
- u("The `licenseKey` option not provided");
88
- }
89
- }, 2e3);
76
+ t.Commands.has(y.settings) && (r = t.runCommand(y.settings), d = (r == null ? void 0 : r.baseUrl) || "");
77
+ const e = (o) => {
78
+ a == null || a(o), o && b(o);
79
+ };
80
+ if (!r) {
81
+ t.onReady(async () => {
82
+ if (!F())
83
+ if (i) {
84
+ const o = await H({ licenseKey: i, pluginName: n, baseApiUrl: d });
85
+ e(o);
86
+ } else
87
+ l("The `licenseKey` option not provided");
88
+ });
89
+ return;
90
+ }
91
+ if (r.licensePlan || r.licenseError) {
92
+ const o = K(r);
93
+ e(o);
94
+ return;
95
+ }
96
+ t.on(N, (o) => e(o));
90
97
  }
98
+ const K = (t) => ({
99
+ sdkLicense: t.license,
100
+ license: t.license,
101
+ error: t.licenseError,
102
+ plan: t.licensePlan
103
+ });
91
104
  async function H(t) {
92
- const { licenseKey: s, pluginName: n, baseApiUrl: a } = t;
105
+ const { licenseKey: s, pluginName: n, baseApiUrl: i } = t;
93
106
  try {
94
- return (await F({
95
- baseApiUrl: a,
107
+ return (await W({
108
+ baseApiUrl: i,
96
109
  path: `/sdk/${s || "na"}`,
97
110
  method: "POST",
98
111
  params: {
@@ -100,29 +113,29 @@ async function H(t) {
100
113
  pn: n
101
114
  }
102
115
  })).result || {};
103
- } catch (r) {
104
- return console.error("Error during SDK license check:", r), !1;
116
+ } catch (a) {
117
+ return console.error("Error during SDK license check:", a), !1;
105
118
  }
106
119
  }
107
- const C = (t, s, n) => {
108
- const { doc: a = document } = n, r = n.target || a.head, c = r.querySelector(`style[${t}]`) || a.createElement("style");
109
- c.setAttribute(t, "true"), c.innerHTML = s, !r.contains(c) && r.appendChild(c);
110
- }, z = (t) => t.dispatchEvent(new CustomEvent("input"));
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"));
111
124
  function V(t, s) {
112
125
  if (!s) return () => {
113
126
  };
114
- const n = t.Components.events, a = (e) => t.getSelectedAll().includes(e), r = (e) => e.isInstanceOf("text") && !e.isChildOf("text"), c = (e) => e.isChildOf("text"), d = (e) => t.getEditing() === e, l = (e, o = {}) => {
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 = {}) => {
115
128
  e.trigger("focus", o.event);
116
- }, i = (e, o) => {
117
- a(e) && r(e) && !d(e) && l(e, o);
118
- }, u = (e, o) => {
119
- if (a(e) && !r(e) && c(e)) {
120
- const b = e.parents().find((x) => x.isInstanceOf("text"));
121
- b && (l(b, o), setTimeout(() => t.select(b), 0));
129
+ }, l = (e, o) => {
130
+ i(e) && a(e) && !d(e) && r(e, o);
131
+ }, b = (e, o) => {
132
+ if (i(e) && !a(e) && c(e)) {
133
+ const u = e.parents().find((x) => x.isInstanceOf("text"));
134
+ u && (r(u, o), setTimeout(() => t.select(u), 0));
122
135
  }
123
136
  };
124
- return t.on(n.select, i), t.on(n.selectBefore, u), () => {
125
- t.off(n.select, i), t.off(n.selectBefore, u);
137
+ return t.on(n.select, l), t.on(n.selectBefore, b), () => {
138
+ t.off(n.select, l), t.off(n.selectBefore, b);
126
139
  };
127
140
  }
128
141
  const J = "rteTinyMce", X = v.startup, Y = `
@@ -232,34 +245,34 @@ const J = "rteTinyMce", X = v.startup, Y = `
232
245
  E.set(t, s);
233
246
  }, Z = (t) => {
234
247
  E.delete(t);
235
- }, T = (t) => E.get(t), y = (t) => {
236
- const s = t.target, n = s.closest(".tox"), a = s.matches(".ephox-snooker-resizer-bar");
237
- (n || a) && t.stopPropagation();
248
+ }, T = (t) => E.get(t), m = (t) => {
249
+ const s = t.target, n = s.closest(".tox"), i = s.matches(".ephox-snooker-resizer-bar");
250
+ (n || i) && t.stopPropagation();
238
251
  }, D = (t) => {
239
252
  t.stopPropagation(), t.preventDefault();
240
253
  }, tt = (t, s) => {
241
- const n = t.getDoc(), a = t.getWin();
254
+ const n = t.getDoc(), i = t.getWin();
242
255
  if (s != null && s.event) {
243
- const { event: r } = s, { clientX: c, clientY: d } = r;
244
- let l;
256
+ const { event: a } = s, { clientX: c, clientY: d } = a;
257
+ let r;
245
258
  if (n.caretRangeFromPoint)
246
- l = n.caretRangeFromPoint(c, d);
259
+ r = n.caretRangeFromPoint(c, d);
247
260
  else if (n.caretPositionFromPoint) {
248
- const i = n.caretPositionFromPoint(c, d);
249
- l = n.createRange(), l == null || l.setStart(i.offsetNode, i.offset);
261
+ const l = n.caretPositionFromPoint(c, d);
262
+ r = n.createRange(), r == null || r.setStart(l.offsetNode, l.offset);
250
263
  }
251
- if (l) {
252
- const i = a.getSelection();
253
- i == null || i.removeAllRanges(), i == null || i.addRange(l), t.selection.setRng(l);
264
+ if (r) {
265
+ const l = i.getSelection();
266
+ l == null || l.removeAllRanges(), l == null || l.addRange(r), t.selection.setRng(r);
254
267
  }
255
268
  } else
256
269
  t.execCommand("SelectAll");
257
270
  }, et = (t) => {
258
- var u, e;
259
- const { el: s, editor: n, componentView: a } = t, r = n.runCommand(m.getStateTheme), c = a.model, d = {
271
+ var b, e;
272
+ const { el: s, editor: n, componentView: i } = t, a = n.runCommand(y.getStateTheme), c = i.model, d = {
260
273
  target: s,
261
274
  inline: !0,
262
- skin: (r == null ? void 0 : r.theme) === I.dark ? "oxide-dark" : "oxide",
275
+ skin: (a == null ? void 0 : a.theme) === L.dark ? "oxide-dark" : "oxide",
263
276
  menubar: !1,
264
277
  image_advtab: !0,
265
278
  paste_data_images: !0,
@@ -273,26 +286,26 @@ const J = "rteTinyMce", X = v.startup, Y = `
273
286
  plugins: "advlist autolink lists link image media table",
274
287
  toolbar_mode: "sliding",
275
288
  toolbar: "bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"
276
- }, l = ((e = (u = t.pluginOpts) == null ? void 0 : u.loadConfig) == null ? void 0 : e.call(u, { config: d, editor: n, componentView: a, component: c })) || {};
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 })) || {};
277
290
  return {
278
291
  ...d,
279
- ...l
292
+ ...r
280
293
  };
281
- }, A = (t, s = document) => new Promise((n, a) => {
282
- const r = Array.isArray(t) ? [...t] : [t], { head: c } = s, d = (l) => {
283
- if (l.length) {
284
- const i = s.createElement("script");
285
- i.src = l.shift(), i.onload = d.bind(null, l), i.onerror = a, c.appendChild(i);
294
+ }, A = (t, s = document) => new Promise((n, i) => {
295
+ const a = Array.isArray(t) ? [...t] : [t], { head: c } = s, d = (r) => {
296
+ 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);
286
299
  } else
287
300
  n();
288
301
  };
289
- d(r);
302
+ d(a);
290
303
  }), ot = function(t, s = {}) {
291
304
  const n = {
292
305
  cdnScript: "https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",
293
306
  ...s
294
- }, { cdnScript: a } = n, r = t.Canvas.events, c = !n.skipCustomTheme, d = "gs-plg-tinymce-studio-theme", l = async (e, o) => {
295
- const b = e.ownerDocument, x = b.defaultView, g = o == null ? void 0 : o.view;
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;
296
309
  if (!x || !g) {
297
310
  console.warn("Missing required data", { win: x, componentView: g });
298
311
  return;
@@ -308,51 +321,51 @@ const J = "rteTinyMce", X = v.startup, Y = `
308
321
  ...h,
309
322
  target: document.createElement("div")
310
323
  }))[0];
311
- return p.ui.show(), b.body.addEventListener("mousedown", y), document.body.addEventListener("mousedown", y), p.on("Change", () => z(e)), p.on("blur", () => p.ui.show()), p.on("OpenWindow", function() {
312
- var _;
313
- const f = (_ = b.querySelector(".tox-dialog")) == null ? void 0 : _.closest(".tox");
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() {
325
+ var P;
326
+ const f = (P = u.querySelector(".tox-dialog")) == null ? void 0 : P.closest(".tox");
314
327
  f && (f == null ? void 0 : f.ownerDocument) !== document && (document.body.appendChild(f), p.once("CloseWindow", () => {
315
- f && f.ownerDocument === document && b.body.appendChild(f);
328
+ f && f.ownerDocument === document && u.body.appendChild(f);
316
329
  }));
317
- }), e.addEventListener("dragstart", D, { capture: !0 }), t.runCommand(m.setStateContextMenu, { enabled: !1 }), tt(p, o), { rteEditor: p, rteEditorShallow: G };
318
- }, i = (e, o) => {
319
- e.ownerDocument.body.removeEventListener("mousedown", y), document.body.removeEventListener("mousedown", y), e.removeEventListener("dragstart", D, { capture: !0 }), t.runCommand(m.setStateContextMenu, { enabled: !0 }), o.rteEditor.destroy(), o.rteEditorShallow.destroy();
330
+ }), e.addEventListener("dragstart", D, { capture: !0 }), t.runCommand(y.setStateContextMenu, { enabled: !1 }), tt(p, o), { rteEditor: p, rteEditorShallow: G };
331
+ }, l = (e, o) => {
332
+ 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();
320
333
  };
321
- t.on(r.frameLoad, async ({ window: e }) => {
334
+ t.on(a.frameLoad, async ({ window: e }) => {
322
335
  const o = e.document;
323
- A(a, o);
336
+ A(i, o);
324
337
  }), t.onReady(() => {
325
- A(a, document), c && C(d, Y, { target: document.body });
338
+ A(i, document), c && z(d, Y, { target: document.body });
326
339
  }), t.setCustomRte({
327
340
  parseContent: !0,
328
341
  // @ts-expect-error - Type 'CustomRteOptions' is missing the following properties from type 'CustomRteOptions': editor, component, el
329
- async enable(e, o, b) {
342
+ async enable(e, o, u) {
330
343
  const x = T(e);
331
344
  if (x) return x.rteEditor;
332
- const g = await l(e, b);
345
+ const g = await r(e, u);
333
346
  return g && Q(e, g), g == null ? void 0 : g.rteEditor;
334
347
  },
335
348
  disable(e) {
336
349
  const o = T(e);
337
- o && (Z(e), i(e, o));
350
+ o && (Z(e), l(e, o));
338
351
  },
339
- getContent(e, o, b) {
352
+ getContent(e, o, u) {
340
353
  var h;
341
354
  const x = T(e), g = x == null ? void 0 : x.rteEditor;
342
- return g && !g.isDirty() ? b.view.lastContent : g ? (h = g.getContent) == null ? void 0 : h.call(g) : e.innerHTML;
355
+ return g && !g.isDirty() ? u.view.lastContent : g ? (h = g.getContent) == null ? void 0 : h.call(g) : e.innerHTML;
343
356
  }
344
357
  });
345
- const u = V(t, n.enableOnClick);
358
+ const b = V(t, n.enableOnClick);
346
359
  q({
347
360
  editor: t,
348
361
  licenseKey: n.licenseKey,
349
362
  plan: X,
350
363
  pluginName: J,
351
364
  cleanup: () => {
352
- t.RichTextEditor.customRte = void 0, u();
365
+ t.RichTextEditor.customRte = void 0, b();
353
366
  }
354
367
  });
355
- }, rt = S(ot);
368
+ }, rt = C(ot);
356
369
  export {
357
370
  rt as default
358
371
  };