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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/accordionComponent/index.cjs.js +5 -5
  2. package/dist/accordionComponent/index.es.js +70 -67
  3. package/dist/accordionComponent/index.js +39 -0
  4. package/dist/accordionComponent/index.umd.js +4 -4
  5. package/dist/aiChat/components/AiChatHeader.d.ts +4 -5
  6. package/dist/aiChat/components/AiChatInput/index.d.ts +4 -5
  7. package/dist/aiChat/components/AiChatMessage.d.ts +7 -8
  8. package/dist/aiChat/components/index.d.ts +1 -1
  9. package/dist/aiChat/components/utils.d.ts +1 -1
  10. package/dist/aiChat/index.cjs.js +10 -376
  11. package/dist/aiChat/index.es.js +4569 -28851
  12. package/dist/aiChat/index.js +10 -376
  13. package/dist/aiChat/index.umd.js +11 -377
  14. package/dist/aiChat/server/index.cjs.d.ts +0 -1
  15. package/dist/aiChat/server/index.cjs.js +45 -45
  16. package/dist/aiChat/server/index.d.ts +0 -1
  17. package/dist/aiChat/server/index.es.d.ts +0 -1
  18. package/dist/aiChat/server/index.es.js +371 -427
  19. package/dist/aiChat/server/index.js +45 -45
  20. package/dist/aiChat/server/index.umd.js +41 -41
  21. package/dist/aiChat/server/stream.test.d.ts +1 -0
  22. package/dist/aiChat/types.d.ts +18 -4
  23. package/dist/aiChat/typesSchema.d.ts +13 -0
  24. package/dist/animationComponent/index.cjs.js +3 -3
  25. package/dist/animationComponent/index.es.js +49 -46
  26. package/dist/animationComponent/index.js +519 -0
  27. package/dist/animationComponent/index.umd.js +3 -3
  28. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  29. package/dist/canvasAbsoluteMode/index.es.js +115 -112
  30. package/dist/canvasAbsoluteMode/index.js +1 -0
  31. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  32. package/dist/canvasEmptyState/index.cjs.js +1 -1
  33. package/dist/canvasEmptyState/index.es.js +71 -68
  34. package/dist/canvasEmptyState/index.js +1 -0
  35. package/dist/canvasEmptyState/index.umd.js +1 -1
  36. package/dist/canvasFullSize/index.cjs.js +3 -3
  37. package/dist/canvasFullSize/index.es.js +69 -66
  38. package/dist/canvasFullSize/index.js +10 -0
  39. package/dist/canvasFullSize/index.umd.js +4 -4
  40. package/dist/canvasGridMode/index.cjs.js +7 -7
  41. package/dist/canvasGridMode/index.es.js +142 -139
  42. package/dist/canvasGridMode/index.js +26 -0
  43. package/dist/canvasGridMode/index.umd.js +7 -7
  44. package/dist/canvasScreenshot/index.cjs.js +1 -1
  45. package/dist/canvasScreenshot/index.es.js +78 -75
  46. package/dist/canvasScreenshot/index.js +1 -0
  47. package/dist/canvasScreenshot/index.umd.js +1 -1
  48. package/dist/dataSourceEjs/EjsExporter.d.ts +1 -1
  49. package/dist/dataSourceEjs/index.cjs.js +3 -3
  50. package/dist/dataSourceEjs/index.es.js +40 -37
  51. package/dist/dataSourceEjs/index.js +21 -0
  52. package/dist/dataSourceEjs/index.umd.js +3 -3
  53. package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
  54. package/dist/dataSourceHandlebars/constants.d.ts +1 -1
  55. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  56. package/dist/dataSourceHandlebars/index.es.js +58 -55
  57. package/dist/dataSourceHandlebars/index.js +10 -0
  58. package/dist/dataSourceHandlebars/index.umd.js +2 -2
  59. package/dist/dialogComponent/index.cjs.js +11 -11
  60. package/dist/dialogComponent/index.es.js +72 -69
  61. package/dist/dialogComponent/index.js +59 -0
  62. package/dist/dialogComponent/index.umd.js +11 -11
  63. package/dist/flexComponent/index.cjs.js +6 -6
  64. package/dist/flexComponent/index.es.js +151 -142
  65. package/dist/flexComponent/index.js +33 -0
  66. package/dist/flexComponent/index.umd.js +8 -8
  67. package/dist/flexComponent/typesSchema.d.ts +1 -1
  68. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  69. package/dist/fsLightboxComponent/index.es.js +93 -90
  70. package/dist/fsLightboxComponent/index.js +6 -0
  71. package/dist/fsLightboxComponent/index.umd.js +3 -3
  72. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  73. package/dist/googleFontsAssetProvider/index.es.js +112 -109
  74. package/dist/googleFontsAssetProvider/index.js +1 -0
  75. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  76. package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
  77. package/dist/iconifyComponent/index.cjs.js +2 -2
  78. package/dist/iconifyComponent/index.es.js +80 -77
  79. package/dist/iconifyComponent/index.js +3 -0
  80. package/dist/iconifyComponent/index.umd.js +2 -2
  81. package/dist/index.cjs.d.ts +1 -0
  82. package/dist/index.cjs.js +970 -82
  83. package/dist/index.d.ts +1 -0
  84. package/dist/index.es.d.ts +1 -0
  85. package/dist/index.es.js +7422 -6145
  86. package/dist/index.umd.js +975 -87
  87. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  88. package/dist/layoutSidebarButtons/index.es.js +95 -92
  89. package/dist/layoutSidebarButtons/index.js +1 -0
  90. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  91. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  92. package/dist/lightGalleryComponent/index.es.js +164 -161
  93. package/dist/lightGalleryComponent/index.js +1 -0
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/lightGalleryComponent/utils.d.ts +1 -1
  96. package/dist/linkImageComponent/index.cjs.js +2 -2
  97. package/dist/linkImageComponent/index.es.js +60 -57
  98. package/dist/linkImageComponent/index.js +12 -0
  99. package/dist/linkImageComponent/index.umd.js +2 -2
  100. package/dist/listPagesComponent/index.cjs.js +4 -4
  101. package/dist/listPagesComponent/index.es.js +57 -54
  102. package/dist/listPagesComponent/index.js +11 -0
  103. package/dist/listPagesComponent/index.umd.js +4 -4
  104. package/dist/listPagesComponent/utils.d.ts +1 -1
  105. package/dist/presetBlockLibrary/blocks.d.ts +6 -0
  106. package/dist/presetBlockLibrary/blocks.test.d.ts +2 -0
  107. package/dist/presetBlockLibrary/emailBlocks.d.ts +53 -0
  108. package/dist/presetBlockLibrary/index.cjs.d.ts +3 -0
  109. package/dist/presetBlockLibrary/index.cjs.js +889 -0
  110. package/dist/presetBlockLibrary/index.d.ts +3 -0
  111. package/dist/presetBlockLibrary/index.es.d.ts +3 -0
  112. package/dist/presetBlockLibrary/index.es.js +1408 -0
  113. package/dist/presetBlockLibrary/index.js +889 -0
  114. package/dist/presetBlockLibrary/index.test.d.ts +1 -0
  115. package/dist/presetBlockLibrary/index.umd.js +889 -0
  116. package/dist/presetBlockLibrary/shared.d.ts +3 -0
  117. package/dist/presetBlockLibrary/types.d.ts +24 -0
  118. package/dist/presetBlockLibrary/typesSchema.d.ts +47 -0
  119. package/dist/presetPrintable/index.cjs.js +3 -3
  120. package/dist/presetPrintable/index.es.js +133 -130
  121. package/dist/presetPrintable/index.js +32 -0
  122. package/dist/presetPrintable/index.umd.js +4 -4
  123. package/dist/prosemirror/index.cjs.js +8 -8
  124. package/dist/prosemirror/index.es.js +552 -549
  125. package/dist/prosemirror/index.js +10 -0
  126. package/dist/prosemirror/index.umd.js +9 -9
  127. package/dist/prosemirror/toolbar.d.ts +2 -2
  128. package/dist/prosemirror/types.d.ts +5 -5
  129. package/dist/rendererReact/index.cjs.js +1 -1
  130. package/dist/rendererReact/index.es.js +137 -134
  131. package/dist/rendererReact/index.js +1 -1
  132. package/dist/rendererReact/index.umd.js +1 -1
  133. package/dist/rteTinyMce/index.cjs.js +2 -2
  134. package/dist/rteTinyMce/index.es.js +74 -71
  135. package/dist/rteTinyMce/index.js +104 -0
  136. package/dist/rteTinyMce/index.umd.js +2 -2
  137. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  138. package/dist/shapeDividerComponent/index.es.js +91 -88
  139. package/dist/shapeDividerComponent/index.js +97 -0
  140. package/dist/shapeDividerComponent/index.umd.js +4 -4
  141. package/dist/swiperComponent/index.cjs.js +7 -7
  142. package/dist/swiperComponent/index.es.js +95 -92
  143. package/dist/swiperComponent/index.js +45 -0
  144. package/dist/swiperComponent/index.umd.js +5 -5
  145. package/dist/tableComponent/index.cjs.js +1 -1
  146. package/dist/tableComponent/index.es.js +181 -178
  147. package/dist/tableComponent/index.js +1 -0
  148. package/dist/tableComponent/index.umd.js +1 -1
  149. package/dist/tableComponent/types.d.ts +3 -3
  150. package/dist/types.d.ts +14 -14
  151. package/dist/utils.d.ts +3 -2
  152. package/dist/utilsDataSources.d.ts +1 -1
  153. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  154. package/dist/youtubeAssetProvider/index.es.js +90 -87
  155. package/dist/youtubeAssetProvider/index.js +1 -0
  156. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  157. package/package.json +182 -34
  158. package/dist/aiChat/server/models.d.ts +0 -15
@@ -1,4 +1,4 @@
1
- import { RteCustomToolbarProps } from '@studio/editor/src/types';
1
+ import { RteCustomToolbarProps } from '@grapesjs/studio-sdk/dist/types';
2
2
  import { EditorView } from 'prosemirror-view';
3
3
  import { RteProseMirrorOptions } from './types';
4
4
  export interface HTMLElementWithView extends HTMLElement {
@@ -37,5 +37,5 @@ export declare const toolbarIcons: {
37
37
  alignTextRight: string;
38
38
  alignTextJustify: string;
39
39
  };
40
- export declare const getToolbarItems: (props: RteCustomToolbarProps, opts: RteProseMirrorOptions) => import('@studio/editor/src/types').RteCustomToolbarResult;
40
+ export declare const getToolbarItems: (props: RteCustomToolbarProps, opts: RteProseMirrorOptions) => import('@grapesjs/studio-sdk/dist/types').RteCustomToolbarResult;
41
41
  export default getToolbarItems;
@@ -1,6 +1,6 @@
1
- import { WithEditorProps } from '@studio/editor/src/typeConfigs/common';
2
- import { StudioLayoutComponentsConfigProps } from '@studio/editor/src/typeConfigs/layoutComponents';
3
- import { RteCustomToolbarProps, RteCustomToolbarResult } from '@studio/editor/src/typeConfigs/rte';
1
+ import { WithEditorProps } from '@grapesjs/studio-sdk/dist/typeConfigs/common';
2
+ import { StudioLayoutComponentsConfigProps } from '@grapesjs/studio-sdk/dist/typeConfigs/layoutComponents';
3
+ import { RteCustomToolbarProps, RteCustomToolbarResult } from '@grapesjs/studio-sdk/dist/typeConfigs/rte';
4
4
  import { ComponentView } from 'grapesjs';
5
5
  import { MarkSpec, Node, Schema } from 'prosemirror-model';
6
6
  import { Plugin, Transaction } from 'prosemirror-state';
@@ -8,8 +8,8 @@ import { EditorView } from 'prosemirror-view';
8
8
  import { BuiltInCommands } from './commands';
9
9
  import { CreateCustomMarkOptions, DefaultSchema } from './schema';
10
10
  import { RteProseMirrorOptionsSchema } from './typesSchema';
11
- export { StudioCommands } from '@studio/editor/src/plugins/global/types';
12
- export type { LayoutCommandProps, RteCustomToolbar } from '@studio/editor/src/types';
11
+ export { StudioCommands } from '@grapesjs/studio-sdk/dist/plugins/global/types';
12
+ export type { LayoutCommandProps, RteCustomToolbar } from '@grapesjs/studio-sdk/dist/types';
13
13
  export type { CreateCustomMarkOptions, DefaultSchema } from './schema';
14
14
  export interface CustomRteOptions extends RteCustomToolbarProps {
15
15
  event?: PointerEvent;
@@ -1 +1 @@
1
- "use strict";const y=require("react/jsx-runtime"),h=require("react"),_=require("react-dom/client"),G="app.grapesjs.com",I="app-stage.grapesjs.com",F="app2.grapesjs.com",M="app-stage2.grapesjs.com",D=[G,F,I,M,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],W="license:check:end",$=()=>typeof window<"u",K=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?I:G}`}/${o?"platform-api":"api"}`,S=()=>{if(!$())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},V=()=>{const e=S();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},z=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function q(e){return typeof e=="function"}async function J({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:a,body:n}){const r=`${t||K({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=a?new URLSearchParams(a).toString():"",d=u?`?${u}`:"",p=await fetch(`${r}${d}`,c);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),x=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.openEditCode="studio:openEditCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(x||{});const L={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function H(e){const t=e;return t.init=o=>s=>e(s,o),t}const Z=e=>H(e);async function Q({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:a,cleanup:n}){let i="",r;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n()},u=(p={})=>{var R;const{error:g,sdkLicense:f}=p,l=(R=p.plan)==null?void 0:R.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],A=L[l];w>A&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(x.settings)&&(r=e.runCommand(x.settings),i=(r==null?void 0:r.baseUrl)||"");const d=p=>{a==null||a(p),p&&u(p)};if(!r){e.onReady(async()=>{if(!V())if(s){const p=await Y({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const p=X(r);d(p);return}e.on(W,p=>d(p))}const X=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Y(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await J({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}function ee(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=z(o);t[s]=e[o]}return t}const te=(e,t)=>{const o=e.components||{};for(const s in o){const a=o[s];if(a.component===t)return{cmpConfig:a,type:s}}};function j(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const a=e[s];if(typeof a=="string"||typeof a=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=a,o=!0}}return o?t:void 0}function oe(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const a=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(a&&n){const i=a.replace(/-([a-z])/g,r=>r[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function ne(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=oe(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=j(o))}catch(o){console.error("Failed to parse style string as JSON",o)}return t}if(Array.isArray(e)){const t={};return e.forEach(o=>{if(typeof o=="object"&&o!==null){const s=o.name||o.property,a=o.value;if(typeof s=="string"&&s&&a!==void 0&&a!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=a}}}),Object.keys(t).length>0?t:void 0}}}function se(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function re(e){var o;const t={};for(const[s,a]of Object.entries(e))if(s==="style")t.style=ne(a);else if(s.startsWith("data-"))t[s]=a;else{const n=se(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ie.has(n)||n.startsWith("svg")?t[n]=a:!ae.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=a:t[n]=a}return t}const ae=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),ie=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),B={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},E=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ce(e){return t=>{const o=t.getContent();E(o)&&t.set({content:P({...e,model:o}),reactContent:o})}}const le=e=>t=>{const o=t.component;E(o)&&(t.component={components:P({...e,model:o})})};function P(e){const{model:t,editor:o,config:s}=e;if(E(t)){const a=t,n={},{type:i,props:r={}}=a,{children:c,className:u,style:d,...p}=r,g=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(q(i)){const l=te(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:f||(n.tagName=i);if(u&&(n.classes=u),d&&(n.style=ee(d)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):P({...e,model:l})).filter(Boolean):N(c)&&(n.components=g(c)),Object.keys(p).length){const l=o.Parser.parserHtml.splitPropsFromAttr(p);n.attributes=l.attrs,Object.assign(n,l.props)}return n}}function pe(e){const{component:t}=e,[o,s]=h.useState(0),[a,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const r=()=>s(l=>l+1),c=()=>{[...t.views].forEach(m=>m.remove()),n(void 0)},{em:u}=t,d=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(g,r),t.on(f,c),()=>{t.off(g,r),t.off(f,c),c()}},[t]),{key:o,view:a,connectDom:r=>{if(!r)return;const c=ue({...e,el:r});n(c)}}}function ue(e){var c;const{editor:t,component:o,el:s,frameView:a}=e,{em:n,Components:i}=t;let r=o.getView(a.model);if((r==null?void 0:r.el)===s)return r;if(!r){const{ComponentView:u}=i,d=o.attributes.type||"default",p=((c=i.getType(d))==null?void 0:c.view)||u,g={...i.config,frameView:a,em:n},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});r=new f({el:s,config:g,model:o})}return r.el=s,r.render(),r}function fe(e,t){const{Components:o}=e,s=({id:a,model:n})=>{n&&o.addType(a,{model:{toJSON(...i){const r=n.prototype.toJSON.apply(this,i);return r.tagName=this.tagName,r}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([a,n])=>{var g,f;const{allowPropClassName:i,allowPropId:r,allowChildren:c}=n,u=!r&&!i,d=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!r});o.addType(a,{isComponent:l=>(l==null?void 0:l.tagName)===a,model:{defaults:{type:a,traits:((g=n.props)==null?void 0:g.call(n))||[],droppable:!!c,stylable:!u,styleManager:d,selectorManager:p,...((f=n.model)==null?void 0:f.defaults)||{}}}})})}function C(e){var O;const{component:t,config:o,editor:s,frameView:a,onMount:n,tagName:i,children:r}=e,{key:c,view:u,connectDom:d}=pe(e);h.useEffect(()=>{if(!u&&!n)return;const v=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const p=t.get("type")||"default",g=t.content,f=(O=o.components)==null?void 0:O[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",m=t.components(),R=m.length?m.map(v=>y.jsx(C,{component:v,config:o,editor:s,frameView:a},v.cid)):[g||void 0],w=re(t.getAttributes()),A=f==null?void 0:f.editorRender,T=[...R,r].filter(v=>v??!1),k=T.length?T:null;if(A)return y.jsx(A,{props:w,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...w,children:k})});if(t.isInstanceOf("textnode"))return g;const U=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:d,key:U},t.get("void")?null:k)}const de=e=>{const{frame:t,window:o,onMount:s,editor:a}=e,n=a.Canvas.events,{root:i}=t;try{const r=_.createRoot(o.document.body);r.render(y.jsx(ge,{...e,component:i,onMount:s}));const c=()=>r.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(r){console.warn(r)}return i.getView()};function ge(e){const{editor:t,component:o,window:s,frameView:a,config:n,onMount:i}=e,r=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:r,editor:t,frameView:a}}:{},d=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(C,{tagName:"div",component:o,config:n,editor:t,frameView:a,onMount:i,children:y.jsx(d,{...u})})})}const ye="rendererReact",he=b.startup,ve=function(e,t={}){const{Blocks:o,Pages:s}=e,a=o.events,n=s.events;e.Canvas.config.customRenderer=r=>de({...r,config:t}),e.Components.config.processor=r=>P({model:r,editor:e,config:t}),fe(e,t);const i=[[a.add,ce({editor:e,config:t})],[n.addBefore,le({editor:e,config:t})]];i.forEach(([r,c])=>e.on(r,c)),Q({editor:e,licenseKey:t.licenseKey,plan:he,pluginName:ye,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([r,c])=>e.off(r,c))}})},be=Z(ve);module.exports=be;
1
+ "use strict";const y=require("react/jsx-runtime"),h=require("react"),F=require("react-dom/client"),I="app.grapesjs.com",G="app-stage.grapesjs.com",M="app2.grapesjs.com",W="app-stage2.grapesjs.com",D=[I,M,G,W,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],$="license:check:end",K=()=>typeof window<"u",V=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:I}`}/${o?"platform-api":"api"}`,z=()=>{if(!K())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},S=()=>{const e=z();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},q=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function J(e){return typeof e=="function"}async function H({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:r,body:n}){const a=`${t||V({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.openEditCode="studio:openEditCode",e.openBlocks="studio:openBlocks",e.appendComponent="studio:appendComponent",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 Z(e,t){const o=e;return o.init=s=>{const r=n=>e(n,s);return r.__gjsPluginId=t,r},o}const Q=(e,t)=>Z(e,t);async function X({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(e,o)},u=(p={})=>{var R;const{error:g,sdkLicense:f}=p,l=(R=p.plan)==null?void 0:R.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],P=L[l];w>P&&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(!S())if(s){const p=await ee({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const p=Y(a);d(p);return}e.on($,p=>d(p))}const Y=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ee(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await H({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 te(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=q(o);t[s]=e[o]}return t}const oe=(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 ne(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 se(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=ne(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 re(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function ae(e){var o;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=se(r);else if(s.startsWith("data-"))t[s]=r;else{const n=re(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ce.has(n)||n.startsWith("svg")?t[n]=r:!ie.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=r:t[n]=r}return t}const ie=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"]),ce=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),B={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},E=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function le(e){return t=>{const o=t.getContent();E(o)&&t.set({content:A({...e,model:o}),reactContent:o})}}const pe=e=>t=>{const o=t.component;E(o)&&(t.component={components:A({...e,model:o})})};function A(e){const{model:t,editor:o,config:s}=e;if(E(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(J(i)){const l=oe(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=te(d)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):A({...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 ue(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=fe({...e,el:a});n(c)}}}function fe(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 de(e,t){const{Components:o}=e,s=({id:r,model:n})=>{n&&o.addType(r,{model:{toJSON(...i){const a=n.prototype.toJSON.apply(this,i);return a.tagName=this.tagName,a}}})};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 C(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}=ue(e);h.useEffect(()=>{if(!u&&!n)return;const v=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const p=t.get("type")||"default",g=t.content,f=(O=o.components)==null?void 0:O[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",m=t.components(),R=m.length?m.map(v=>y.jsx(C,{component:v,config:o,editor:s,frameView:r},v.cid)):[g||void 0],w=ae(t.getAttributes()),P=f==null?void 0:f.editorRender,T=[...R,a].filter(v=>v??!1),k=T.length?T:null;if(P)return y.jsx(P,{props:w,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...w,children:k})});if(t.isInstanceOf("textnode"))return g;const _=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:d,key:_},t.get("void")?null:k)}const ge=e=>{const{frame:t,window:o,onMount:s,editor:r}=e,n=r.Canvas.events,{root:i}=t;try{const a=F.createRoot(o.document.body);a.render(y.jsx(ye,{...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 ye(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(C,{tagName:"div",component:o,config:n,editor:t,frameView:r,onMount:i,children:y.jsx(d,{...u})})})}const U="rendererReact",he=b.startup,ve=function(e,t={}){const{Blocks:o,Pages:s}=e,r=o.events,n=s.events;e.Canvas.config.customRenderer=a=>ge({...a,config:t}),e.Components.config.processor=a=>A({model:a,editor:e,config:t}),de(e,t);const i=[[r.add,le({editor:e,config:t})],[n.addBefore,pe({editor:e,config:t})]];i.forEach(([a,c])=>e.on(a,c)),X({editor:e,licenseKey:t.licenseKey,plan:he,pluginName:U,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([a,c])=>e.off(a,c))}})},be=Q(ve,U);module.exports=be;