@grapesjs/studio-sdk-plugins 1.0.36 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +4 -4
- package/dist/accordionComponent/index.es.js +83 -70
- package/dist/accordionComponent/index.umd.js +4 -4
- package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
- package/dist/aiChat/components/utils.d.ts +1 -0
- package/dist/aiChat/components/utilsTw.d.ts +11 -0
- package/dist/aiChat/index.cjs.js +70 -70
- package/dist/aiChat/index.es.js +8627 -8161
- package/dist/aiChat/index.js +70 -70
- package/dist/aiChat/index.umd.js +70 -70
- package/dist/aiChat/projectGeneration.d.ts +17 -0
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +55 -42
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +67 -54
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +59 -46
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +4 -4
- package/dist/canvasFullSize/index.es.js +59 -46
- package/dist/canvasFullSize/index.umd.js +4 -4
- package/dist/canvasGridMode/index.cjs.js +2 -2
- package/dist/canvasGridMode/index.es.js +70 -57
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +37 -24
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +51 -38
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/index.cjs.js +2 -2
- package/dist/dataSourceHandlebars/index.es.js +50 -37
- package/dist/dataSourceHandlebars/index.umd.js +6 -6
- package/dist/dialogComponent/index.cjs.js +9 -9
- package/dist/dialogComponent/index.es.js +58 -45
- package/dist/dialogComponent/index.umd.js +3 -3
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +82 -69
- package/dist/flexComponent/index.umd.js +6 -6
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +70 -57
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +84 -71
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +82 -69
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +36 -36
- package/dist/index.es.js +843 -830
- package/dist/index.umd.js +36 -36
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +81 -68
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +86 -73
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +70 -57
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +49 -36
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +130 -117
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +96 -83
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +143 -131
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +74 -61
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +3 -3
- package/dist/shapeDividerComponent/index.es.js +33 -20
- package/dist/shapeDividerComponent/index.umd.js +3 -3
- package/dist/swiperComponent/index.cjs.js +5 -5
- package/dist/swiperComponent/index.es.js +105 -92
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +163 -150
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +36 -23
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const T=require("handlebars/dist/cjs/handlebars"),$="app.grapesjs.com",x="app-stage.grapesjs.com",k="app2.grapesjs.com",A="app-stage2.grapesjs.com",b=[$,k,x,A,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:end",N=()=>typeof window<"u",R=({isDev:e,isStage:t,isPlatform:s})=>`${e?"":`https://${t?x:$}`}/${s?"platform-api":"api"}`,O=()=>{const e=N()&&window.location.hostname;return!!e&&(b.includes(e)||b.some(t=>e.endsWith(t)))};async function _({path:e,baseApiUrl:t,method:s="GET",headers:n={},params:a,body:r}){const i=`${t||R({isDev:!1,isStage:!1})}${e}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",h=u?`?${u}`:"",l=await fetch(`${i}${h}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{}),d=(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))(d||{});const m={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function w(e){const t=e;return t.init=s=>n=>e(n,s),t}const D=e=>w(e);async function G({editor:e,plan:t,pluginName:s,licenseKey:n,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",s,"Reason:",l),r()},u=(l={})=>{var P;const{error:y,sdkLicense:E}=l,g=(P=l.plan)==null?void 0:P.category;if(!(E||l.license)||y)c(y||"Invalid license");else if(g){const I=m[t],S=m[g];I>S&&c({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(d.settings)&&(i=e.runCommand(d.settings),o=(i==null?void 0:i.baseUrl)||"");const h=l=>{a==null||a(l),l&&u(l)};if(!i){e.onReady(async()=>{if(!O())if(n){const l=await B({licenseKey:n,pluginName:s,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=M(i);h(l);return}e.on(L,l=>h(l))}const M=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function B(e){const{licenseKey:t,pluginName:s,baseApiUrl:n}=e;try{return(await _({baseApiUrl:n,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const j=(e,t)=>(e.config.optsHtml={...e.config.optsHtml,exporter:t},()=>{e.config.optsHtml.exporter=void 0}),U=(e,t)=>{const s=a=>{const{input:r}=a,{contains:o}=t;(!o||r.includes(o))&&(a.input=t.importer.import(r))},n=e.Parser.events.htmlBefore;return e.on(n,s),()=>{e.off(n,s)}},v={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},H={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},W={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},V={...v,...H,...W};class F{getHelperId(t){return V[t]||t}getFullPath({collectionId:t,path:s}){let n=s;return t&&(n=[this._sanitizeVariableName(t),s].filter(Boolean).join(".")),n||""}getVariableSyntax({dataResolver:t}){const{defaultValue:s}=t,n=this.getFullPath(t);return s?`{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}`:`{{{${n}}}}`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:s,dataSource:n}=t,a=n==null?void 0:n.path;let r="";if(t.startIndex!==void 0||t.endIndex!==void 0){const u=t.startIndex??0,h=t.endIndex!==void 0?t.endIndex:"";h!==""?r=` (slice ${a} ${u} ${h})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(s)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:t}){const s=t.condition;if(!s)return"";const n=s,a=s;if(a.statements&&a.logicalOperator==="and"||a.logicalOperator==="or"){const{statements:r}=a,o=a.logicalOperator,i=r.map(u=>this._parseCondition(u)).join(" ");return`{{#if ${r.length>1?`(${o} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(n)}}}`}_parseCondition(t){if(!t)return"";const s=t,n=t;if(n.statements&&n.logicalOperator==="and"||n.logicalOperator==="or"){const{statements:a}=n,r=n.logicalOperator,o=n.statements.map(i=>this._parseCondition(i)).join(" ");return a.length>1?`(${r} ${o})`:o}else{const a=s.operator,r=this.getHelperId(a),o=this._parseValue(s.left),i=this._parseValue(s.right);return this.getExpressionStr(r,o,i)}}getExpressionStr(t,s,n){return v[t]?t==="isTruthy"?s:t==="isFalsy"?`!${s}`:`${t} ${s}`:`(${t} ${s} ${n})`}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class C{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];const s=this.parse(t);return this.astToGrapesJS(s)}parse(t){try{return T.parse(t)}catch(s){if(s instanceof Error&&s.message.includes("Parse error")){const n=s.message.match(/line (\d+)/),a=n?parseInt(n[1]):0,r=s.message.match(/column (\d+)/),o=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`)}throw s}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"ContentStatement":return this.handleContentStatement(t);case"MustacheStatement":return this.handleMustacheStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"PartialStatement":return this.handlePartialStatement(t);case"CommentStatement":return this.handleCommentStatement(t);case"ElementNode":return this.handleElementNode(t);case"TextNode":return this.handleTextNode(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`,t.loc),""}}handleProgram(t){let s="";if(t.body)for(const n of t.body)s+=this.astToGrapesJS(n);return s}handleContentStatement(t){return t.value||""}handleMustacheStatement(t,s={}){const n=this.getExpressionString(t.path),a={...s};return this.collectionStack.length>0?this.processPathWithCollectionContext(n,a):a.path=n,`<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`}processPathWithCollectionContext(t,s){t.startsWith("@")?this.handleDirectCollectionReference(t,s):this.handleRelativePathReference(t,s)}handleDirectCollectionReference(t,s){if(this.isSpecialIterationVariable(t)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],t,s);return}const[n,...a]=t.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(n)?this.setCurrentItemResolver(n,r,s):this.handleParentReferenceFallback(t,s)}isSpecialIterationVariable(t){return["index","@index","key","@key"].includes(t)}setSpecialVariableResolver(t,s,n){n.collectionId=t;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};n.variableType=a[s]}setCurrentItemResolver(t,s,n){n.collectionId=t,n.variableType="currentItem",s&&(n.path=s)}handleRelativePathReference(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}calculateParentLevel(t){const s=this.collectionStack.findLastIndex(r=>r===t[0]);if(s!==-1)return{parentLevel:this.collectionStack.length-1-s,remainingPathParts:t.slice(1)};let n=0;const a=[...t];for(;a[0]==="..";)n++,a.shift();return{parentLevel:n,remainingPathParts:a}}resolveRelativePath(t,s,n){const a=this.collectionStack[s];n.collectionId=a,n.variableType="currentItem",t!=="this"&&(n.path=t.startsWith("this.")?t.split(".").slice(1).join("."):t)}handleParentReferenceFallback(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}handleBlockStatement(t){const s=t.path.original;switch(s){case"if":case"unless":return this.handleConditionalBlock(t,s);case"each":return this.handleEachBlock(t);default:return this.addMessage("warning",`Unsupported block helper: ${s}`,t.loc),this.handleGenericBlock(t)}}handleConditionalBlock(t,s){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(t.params[0])},operator:s==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(t.program),i=t.inverse?this.handleProgram(t.inverse):"";return`
|
|
1
|
+
"use strict";const T=require("handlebars/dist/cjs/handlebars"),x="app.grapesjs.com",$="app-stage.grapesjs.com",k="app2.grapesjs.com",A="app-stage2.grapesjs.com",P=[x,k,$,A,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],L="license:check:end",N=()=>typeof window<"u",R=({isDev:e,isStage:t,isPlatform:s})=>`${e?"":`https://${t?$:x}`}/${s?"platform-api":"api"}`,O=()=>{if(!N())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},_=()=>{const e=O();return!!e&&(P.includes(e)||P.some(t=>e.endsWith(t)))};async function w({path:e,baseApiUrl:t,method:s="GET",headers:n={},params:a,body:r}){const i=`${t||R({isDev:!1,isStage:!1})}${e}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",h=u?`?${u}`:"",l=await fetch(`${i}${h}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{}),d=(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))(d||{});const m={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function D(e){const t=e;return t.init=s=>n=>e(n,s),t}const G=e=>D(e);async function M({editor:e,plan:t,pluginName:s,licenseKey:n,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",s,"Reason:",l),r()},u=(l={})=>{var b;const{error:y,sdkLicense:E}=l,g=(b=l.plan)==null?void 0:b.category;if(!(E||l.license)||y)c(y||"Invalid license");else if(g){const I=m[t],S=m[g];I>S&&c({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(d.settings)&&(i=e.runCommand(d.settings),o=(i==null?void 0:i.baseUrl)||"");const h=l=>{a==null||a(l),l&&u(l)};if(!i){e.onReady(async()=>{if(!_())if(n){const l=await j({licenseKey:n,pluginName:s,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=B(i);h(l);return}e.on(L,l=>h(l))}const B=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function j(e){const{licenseKey:t,pluginName:s,baseApiUrl:n}=e;try{return(await w({baseApiUrl:n,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const U=(e,t)=>(e.config.optsHtml={...e.config.optsHtml,exporter:t},()=>{e.config.optsHtml.exporter=void 0}),H=(e,t)=>{const s=a=>{const{input:r}=a,{contains:o}=t;(!o||r.includes(o))&&(a.input=t.importer.import(r))},n=e.Parser.events.htmlBefore;return e.on(n,s),()=>{e.off(n,s)}},v={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},W={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},V={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},F={...v,...W,...V};class C{getHelperId(t){return F[t]||t}getFullPath({collectionId:t,path:s}){let n=s;return t&&(n=[this._sanitizeVariableName(t),s].filter(Boolean).join(".")),n||""}getVariableSyntax({dataResolver:t}){const{defaultValue:s}=t,n=this.getFullPath(t);return s?`{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}`:`{{{${n}}}}`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:s,dataSource:n}=t,a=n==null?void 0:n.path;let r="";if(t.startIndex!==void 0||t.endIndex!==void 0){const u=t.startIndex??0,h=t.endIndex!==void 0?t.endIndex:"";h!==""?r=` (slice ${a} ${u} ${h})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(s)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:t}){const s=t.condition;if(!s)return"";const n=s,a=s;if(a.statements&&a.logicalOperator==="and"||a.logicalOperator==="or"){const{statements:r}=a,o=a.logicalOperator,i=r.map(u=>this._parseCondition(u)).join(" ");return`{{#if ${r.length>1?`(${o} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(n)}}}`}_parseCondition(t){if(!t)return"";const s=t,n=t;if(n.statements&&n.logicalOperator==="and"||n.logicalOperator==="or"){const{statements:a}=n,r=n.logicalOperator,o=n.statements.map(i=>this._parseCondition(i)).join(" ");return a.length>1?`(${r} ${o})`:o}else{const a=s.operator,r=this.getHelperId(a),o=this._parseValue(s.left),i=this._parseValue(s.right);return this.getExpressionStr(r,o,i)}}getExpressionStr(t,s,n){return v[t]?t==="isTruthy"?s:t==="isFalsy"?`!${s}`:`${t} ${s}`:`(${t} ${s} ${n})`}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class q{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];const s=this.parse(t);return this.astToGrapesJS(s)}parse(t){try{return T.parse(t)}catch(s){if(s instanceof Error&&s.message.includes("Parse error")){const n=s.message.match(/line (\d+)/),a=n?parseInt(n[1]):0,r=s.message.match(/column (\d+)/),o=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`)}throw s}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"ContentStatement":return this.handleContentStatement(t);case"MustacheStatement":return this.handleMustacheStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"PartialStatement":return this.handlePartialStatement(t);case"CommentStatement":return this.handleCommentStatement(t);case"ElementNode":return this.handleElementNode(t);case"TextNode":return this.handleTextNode(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`,t.loc),""}}handleProgram(t){let s="";if(t.body)for(const n of t.body)s+=this.astToGrapesJS(n);return s}handleContentStatement(t){return t.value||""}handleMustacheStatement(t,s={}){const n=this.getExpressionString(t.path),a={...s};return this.collectionStack.length>0?this.processPathWithCollectionContext(n,a):a.path=n,`<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`}processPathWithCollectionContext(t,s){t.startsWith("@")?this.handleDirectCollectionReference(t,s):this.handleRelativePathReference(t,s)}handleDirectCollectionReference(t,s){if(this.isSpecialIterationVariable(t)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],t,s);return}const[n,...a]=t.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(n)?this.setCurrentItemResolver(n,r,s):this.handleParentReferenceFallback(t,s)}isSpecialIterationVariable(t){return["index","@index","key","@key"].includes(t)}setSpecialVariableResolver(t,s,n){n.collectionId=t;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};n.variableType=a[s]}setCurrentItemResolver(t,s,n){n.collectionId=t,n.variableType="currentItem",s&&(n.path=s)}handleRelativePathReference(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}calculateParentLevel(t){const s=this.collectionStack.findLastIndex(r=>r===t[0]);if(s!==-1)return{parentLevel:this.collectionStack.length-1-s,remainingPathParts:t.slice(1)};let n=0;const a=[...t];for(;a[0]==="..";)n++,a.shift();return{parentLevel:n,remainingPathParts:a}}resolveRelativePath(t,s,n){const a=this.collectionStack[s];n.collectionId=a,n.variableType="currentItem",t!=="this"&&(n.path=t.startsWith("this.")?t.split(".").slice(1).join("."):t)}handleParentReferenceFallback(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}handleBlockStatement(t){const s=t.path.original;switch(s){case"if":case"unless":return this.handleConditionalBlock(t,s);case"each":return this.handleEachBlock(t);default:return this.addMessage("warning",`Unsupported block helper: ${s}`,t.loc),this.handleGenericBlock(t)}}handleConditionalBlock(t,s){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(t.params[0])},operator:s==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(t.program),i=t.inverse?this.handleProgram(t.inverse):"";return`
|
|
2
2
|
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
|
|
3
3
|
<data-condition-true-content>${o}</data-condition-true-content>
|
|
4
4
|
<data-condition-false-content>${i}</data-condition-false-content>
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:s},collectionId:n})}'>
|
|
8
8
|
<data-collection-item>${a}</data-collection-item>
|
|
9
9
|
</data-collection>
|
|
10
|
-
`}handleCommentStatement(t){return`<!--${t.value}-->`}handleElementNode(t){let s="";if(t.attributes)for(const a of t.attributes)a.value.type==="TextNode"?s+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,t.loc),s+=` ${a.name}="${this.getExpressionString(a.value)}"`);let n="";if(t.children)for(const a of t.children)n+=this.astToGrapesJS(a);return`<${t.tag}${s}>${n}</${t.tag}>`}handleTextNode(t){return t.chars||""}handlePartialStatement(t){return this.addMessage("warning",`Partials are not fully supported: ${t.name.original}`,t.loc),`{{> ${t.name.original}}}`}handleGenericBlock(t){const s=this.handleProgram(t.program);return`<!-- Unsupported block: ${t.path.original} -->${s}`}getExpressionString(t){return t.type==="PathExpression"?t.original:t.type==="StringLiteral"?t.value:t.type==="NumberLiteral"?t.value.toString():t.type==="BooleanLiteral"?t.value?"true":"false":t.type==="SubExpression"?this.getExpressionString(t.params[0]):t.type==="Hash"?`{${t.pairs.map(n=>`${n.key}=${this.getExpressionString(n.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${t.type}`,t.loc),"")}addMessage(t,s,n){this.messages.push({type:t,message:s,location:n?{line:n.start.line,column:n.start.column}:void 0})}}const f=e=>{if(e==null||e==="")return[];if(e===".")return["this"];if(e===".."||e==="../")return[".."];if(e.startsWith("../")){const o=e.substring(3);return["..",...f(o)]}const t=[];let s=0,n=e.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const h=c!==void 0?c:u||"";return t[s]=h,`__HANDLEBARS_PLACEHOLDER_${s++}__`});n=n.replace(/\//g,".");const a=n.split("."),r=[];for(const o of a){const i=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);if(i){const c=parseInt(i[1],10);r.push(t[c])}else o!==""&&r.push(o)}return r},
|
|
10
|
+
`}handleCommentStatement(t){return`<!--${t.value}-->`}handleElementNode(t){let s="";if(t.attributes)for(const a of t.attributes)a.value.type==="TextNode"?s+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,t.loc),s+=` ${a.name}="${this.getExpressionString(a.value)}"`);let n="";if(t.children)for(const a of t.children)n+=this.astToGrapesJS(a);return`<${t.tag}${s}>${n}</${t.tag}>`}handleTextNode(t){return t.chars||""}handlePartialStatement(t){return this.addMessage("warning",`Partials are not fully supported: ${t.name.original}`,t.loc),`{{> ${t.name.original}}}`}handleGenericBlock(t){const s=this.handleProgram(t.program);return`<!-- Unsupported block: ${t.path.original} -->${s}`}getExpressionString(t){return t.type==="PathExpression"?t.original:t.type==="StringLiteral"?t.value:t.type==="NumberLiteral"?t.value.toString():t.type==="BooleanLiteral"?t.value?"true":"false":t.type==="SubExpression"?this.getExpressionString(t.params[0]):t.type==="Hash"?`{${t.pairs.map(n=>`${n.key}=${this.getExpressionString(n.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${t.type}`,t.loc),"")}addMessage(t,s,n){this.messages.push({type:t,message:s,location:n?{line:n.start.line,column:n.start.column}:void 0})}}const f=e=>{if(e==null||e==="")return[];if(e===".")return["this"];if(e===".."||e==="../")return[".."];if(e.startsWith("../")){const o=e.substring(3);return["..",...f(o)]}const t=[];let s=0,n=e.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const h=c!==void 0?c:u||"";return t[s]=h,`__HANDLEBARS_PLACEHOLDER_${s++}__`});n=n.replace(/\//g,".");const a=n.split("."),r=[];for(const o of a){const i=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);if(i){const c=parseInt(i[1],10);r.push(t[c])}else o!==""&&r.push(o)}return r},J="dataSourceHandlebars",z=p.startup,K=function(e,t={}){const s=U(e,new C),n=H(e,{contains:"{{",importer:new q});M({editor:e,licenseKey:t.licenseKey,plan:z,pluginName:J,cleanup:()=>{s(),n()}})},Y=G(K);module.exports=Y;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import T from "handlebars/dist/cjs/handlebars";
|
|
2
|
-
const
|
|
3
|
-
$,
|
|
4
|
-
k,
|
|
2
|
+
const x = "app.grapesjs.com", $ = "app-stage.grapesjs.com", k = "app2.grapesjs.com", A = "app-stage2.grapesjs.com", P = [
|
|
5
3
|
x,
|
|
4
|
+
k,
|
|
5
|
+
$,
|
|
6
6
|
A,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
@@ -10,17 +10,30 @@ const $ = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = "app2.grapesjs.c
|
|
|
10
10
|
// For stackblitz.com demos
|
|
11
11
|
".local.webcontainer.io",
|
|
12
12
|
// For stackblitz.com demos
|
|
13
|
-
"-sandpack.codesandbox.io"
|
|
13
|
+
"-sandpack.codesandbox.io",
|
|
14
14
|
// For Sandpack demos
|
|
15
|
+
".claudemcpcontent.com",
|
|
16
|
+
// For Claude mcp app
|
|
17
|
+
".web-sandbox.oaiusercontent.com"
|
|
18
|
+
// For OpenAI mcp app
|
|
15
19
|
], L = "license:check:end", N = () => typeof window < "u", R = ({
|
|
16
20
|
isDev: e,
|
|
17
21
|
isStage: t,
|
|
18
22
|
isPlatform: s
|
|
19
|
-
}) => `${e ? "" : `https://${t ?
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
}) => `${e ? "" : `https://${t ? $ : x}`}/${s ? "platform-api" : "api"}`, O = () => {
|
|
24
|
+
if (!N()) return "";
|
|
25
|
+
const { hostname: e } = window.location;
|
|
26
|
+
if (e) return e;
|
|
27
|
+
try {
|
|
28
|
+
return window.parent.location.hostname || "";
|
|
29
|
+
} catch {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
}, _ = () => {
|
|
33
|
+
const e = O();
|
|
34
|
+
return !!e && (P.includes(e) || P.some((t) => e.endsWith(t)));
|
|
22
35
|
};
|
|
23
|
-
async function
|
|
36
|
+
async function w({
|
|
24
37
|
path: e,
|
|
25
38
|
baseApiUrl: t,
|
|
26
39
|
method: s = "GET",
|
|
@@ -48,12 +61,12 @@ const m = {
|
|
|
48
61
|
[p.business]: 20,
|
|
49
62
|
[p.enterprise]: 30
|
|
50
63
|
};
|
|
51
|
-
function
|
|
64
|
+
function D(e) {
|
|
52
65
|
const t = e;
|
|
53
66
|
return t.init = (s) => (n) => e(n, s), t;
|
|
54
67
|
}
|
|
55
|
-
const
|
|
56
|
-
async function
|
|
68
|
+
const G = (e) => /* @__PURE__ */ D(e);
|
|
69
|
+
async function M({
|
|
57
70
|
editor: e,
|
|
58
71
|
plan: t,
|
|
59
72
|
pluginName: s,
|
|
@@ -65,8 +78,8 @@ async function G({
|
|
|
65
78
|
const c = (l) => {
|
|
66
79
|
console.warn("Cleanup plugin:", s, "Reason:", l), r();
|
|
67
80
|
}, u = (l = {}) => {
|
|
68
|
-
var
|
|
69
|
-
const { error: y, sdkLicense: E } = l, g = (
|
|
81
|
+
var b;
|
|
82
|
+
const { error: y, sdkLicense: E } = l, g = (b = l.plan) == null ? void 0 : b.category;
|
|
70
83
|
if (!(E || l.license) || y)
|
|
71
84
|
c(y || "Invalid license");
|
|
72
85
|
else if (g) {
|
|
@@ -80,9 +93,9 @@ async function G({
|
|
|
80
93
|
};
|
|
81
94
|
if (!i) {
|
|
82
95
|
e.onReady(async () => {
|
|
83
|
-
if (!
|
|
96
|
+
if (!_())
|
|
84
97
|
if (n) {
|
|
85
|
-
const l = await
|
|
98
|
+
const l = await j({ licenseKey: n, pluginName: s, baseApiUrl: o });
|
|
86
99
|
h(l);
|
|
87
100
|
} else
|
|
88
101
|
c("The `licenseKey` option not provided");
|
|
@@ -90,22 +103,22 @@ async function G({
|
|
|
90
103
|
return;
|
|
91
104
|
}
|
|
92
105
|
if (i.licensePlan || i.licenseError) {
|
|
93
|
-
const l =
|
|
106
|
+
const l = B(i);
|
|
94
107
|
h(l);
|
|
95
108
|
return;
|
|
96
109
|
}
|
|
97
110
|
e.on(L, (l) => h(l));
|
|
98
111
|
}
|
|
99
|
-
const
|
|
112
|
+
const B = (e) => ({
|
|
100
113
|
sdkLicense: e.license,
|
|
101
114
|
license: e.license,
|
|
102
115
|
error: e.licenseError,
|
|
103
116
|
plan: e.licensePlan
|
|
104
117
|
});
|
|
105
|
-
async function
|
|
118
|
+
async function j(e) {
|
|
106
119
|
const { licenseKey: t, pluginName: s, baseApiUrl: n } = e;
|
|
107
120
|
try {
|
|
108
|
-
return (await
|
|
121
|
+
return (await w({
|
|
109
122
|
baseApiUrl: n,
|
|
110
123
|
path: `/sdk/${t || "na"}`,
|
|
111
124
|
method: "POST",
|
|
@@ -118,12 +131,12 @@ async function B(e) {
|
|
|
118
131
|
return console.error("Error during SDK license check:", a), !1;
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
|
-
const
|
|
134
|
+
const U = (e, t) => (e.config.optsHtml = {
|
|
122
135
|
...e.config.optsHtml,
|
|
123
136
|
exporter: t
|
|
124
137
|
}, () => {
|
|
125
138
|
e.config.optsHtml.exporter = void 0;
|
|
126
|
-
}),
|
|
139
|
+
}), H = (e, t) => {
|
|
127
140
|
const s = (a) => {
|
|
128
141
|
const { input: r } = a, { contains: o } = t;
|
|
129
142
|
(!o || r.includes(o)) && (a.input = t.importer.import(r));
|
|
@@ -144,27 +157,27 @@ const j = (e, t) => (e.config.optsHtml = {
|
|
|
144
157
|
isNumber: "isNumber",
|
|
145
158
|
isBoolean: "isBoolean",
|
|
146
159
|
isDefaultValue: "isDefaultValue"
|
|
147
|
-
},
|
|
160
|
+
}, W = {
|
|
148
161
|
">": "numGt",
|
|
149
162
|
"<": "numLt",
|
|
150
163
|
">=": "numGte",
|
|
151
164
|
"<=": "numLte",
|
|
152
165
|
"=": "numEq",
|
|
153
166
|
"!=": "numNeq"
|
|
154
|
-
},
|
|
167
|
+
}, V = {
|
|
155
168
|
contains: "strContains",
|
|
156
169
|
startsWith: "strStartsWith",
|
|
157
170
|
endsWith: "strEndsWith",
|
|
158
171
|
equalsIgnoreCase: "strEqualsIgnoreCase",
|
|
159
172
|
trimEquals: "strTrimEquals"
|
|
160
|
-
},
|
|
173
|
+
}, F = {
|
|
161
174
|
...v,
|
|
162
|
-
...
|
|
163
|
-
...
|
|
175
|
+
...W,
|
|
176
|
+
...V
|
|
164
177
|
};
|
|
165
|
-
class
|
|
178
|
+
class C {
|
|
166
179
|
getHelperId(t) {
|
|
167
|
-
return
|
|
180
|
+
return F[t] || t;
|
|
168
181
|
}
|
|
169
182
|
getFullPath({ collectionId: t, path: s }) {
|
|
170
183
|
let n = s;
|
|
@@ -224,7 +237,7 @@ class F {
|
|
|
224
237
|
return "{{/if}}";
|
|
225
238
|
}
|
|
226
239
|
}
|
|
227
|
-
class
|
|
240
|
+
class q {
|
|
228
241
|
constructor() {
|
|
229
242
|
this.messages = [], this.collectionStack = [];
|
|
230
243
|
}
|
|
@@ -437,21 +450,21 @@ const f = (e) => {
|
|
|
437
450
|
} else o !== "" && r.push(o);
|
|
438
451
|
}
|
|
439
452
|
return r;
|
|
440
|
-
},
|
|
441
|
-
const s =
|
|
453
|
+
}, J = "dataSourceHandlebars", z = p.startup, K = function(e, t = {}) {
|
|
454
|
+
const s = U(e, new C()), n = H(e, {
|
|
442
455
|
contains: "{{",
|
|
443
|
-
importer: new
|
|
456
|
+
importer: new q()
|
|
444
457
|
});
|
|
445
|
-
|
|
458
|
+
M({
|
|
446
459
|
editor: e,
|
|
447
460
|
licenseKey: t.licenseKey,
|
|
448
|
-
plan:
|
|
449
|
-
pluginName:
|
|
461
|
+
plan: z,
|
|
462
|
+
pluginName: J,
|
|
450
463
|
cleanup: () => {
|
|
451
464
|
s(), n();
|
|
452
465
|
}
|
|
453
466
|
});
|
|
454
|
-
},
|
|
467
|
+
}, Q = G(K);
|
|
455
468
|
export {
|
|
456
|
-
|
|
469
|
+
Q as default
|
|
457
470
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(p,g){typeof exports=="object"&&typeof module<"u"?module.exports=g(require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["handlebars/dist/cjs/handlebars"],g):(p=typeof globalThis<"u"?globalThis:p||self,p.StudioSdkPlugins_dataSourceHandlebars=g(p.Handlebars))})(this,function(p){"use strict";const g="app.grapesjs.com",y="app-stage.grapesjs.com",m=[g,"app2.grapesjs.com",y,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],I="license:check:end",S=()=>typeof window<"u",T=({isDev:t,isStage:e,isPlatform:s})=>`${t?"":`https://${e?y:g}`}/${s?"platform-api":"api"}`,k=()=>{const t=S()&&window.location.hostname;return!!t&&(m.includes(t)||m.some(e=>t.endsWith(e)))};async function A({path:t,baseApiUrl:e,method:s="GET",headers:n={},params:a,body:i}){const r=`${e||T({isDev:!1,isStage:!1})}${t}`,c={method:s,headers:{"Content-Type":"application/json",...n}};i&&(c.body=JSON.stringify(i));const u=a?new URLSearchParams(a).toString():"",h=u?`?${u}`:"",l=await fetch(`${r}${h}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var d=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(d||{}),f=(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))(f||{});const x={[d.free]:0,[d.startup]:10,[d.business]:20,[d.enterprise]:30};function N(t){const e=t;return e.init=s=>n=>t(n,s),e}const O=t=>N(t);async function R({editor:t,plan:e,pluginName:s,licenseKey:n,onLicenseCheckResponse:a,cleanup:i}){let o="",r;const c=l=>{console.warn("Cleanup plugin:",s,"Reason:",l),i()},u=(l={})=>{var E;const{error:v,sdkLicense:H}=l,b=(E=l.plan)==null?void 0:E.category;if(!(H||l.license)||v)c(v||"Invalid license");else if(b){const W=x[e],V=x[b];W>V&&c({pluginRequiredPlan:e,licensePlan:b})}};t.Commands.has(f.settings)&&(r=t.runCommand(f.settings),o=(r==null?void 0:r.baseUrl)||"");const h=l=>{a==null||a(l),l&&u(l)};if(!r){t.onReady(async()=>{if(!k())if(n){const l=await L({licenseKey:n,pluginName:s,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const l=_(r);h(l);return}t.on(I,l=>h(l))}const _=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function L(t){const{licenseKey:e,pluginName:s,baseApiUrl:n}=t;try{return(await A({baseApiUrl:n,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const D=(t,e)=>(t.config.optsHtml={...t.config.optsHtml,exporter:e},()=>{t.config.optsHtml.exporter=void 0}),G=(t,e)=>{const s=a=>{const{input:i}=a,{contains:o}=e;(!o||i.includes(o))&&(a.input=e.importer.import(i))},n=t.Parser.events.htmlBefore;return t.on(n,s),()=>{t.off(n,s)}},$={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},M={...$,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class w{getHelperId(e){return M[e]||e}getFullPath({collectionId:e,path:s}){let n=s;return e&&(n=[this._sanitizeVariableName(e),s].filter(Boolean).join(".")),n||""}getVariableSyntax({dataResolver:e}){const{defaultValue:s}=e,n=this.getFullPath(e);return s?`{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}`:`{{{${n}}}}`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:s,dataSource:n}=e,a=n==null?void 0:n.path;let i="";if(e.startIndex!==void 0||e.endIndex!==void 0){const u=e.startIndex??0,h=e.endIndex!==void 0?e.endIndex:"";h!==""?i=` (slice ${a} ${u} ${h})`:i=` (slice ${a} ${u})`}const r=` as |${this._sanitizeVariableName(s)}|`;return`{{#each ${i||a}${r}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:e}){const s=e.condition;if(!s)return"";const n=s,a=s;if(a.statements&&a.logicalOperator==="and"||a.logicalOperator==="or"){const{statements:i}=a,o=a.logicalOperator,r=i.map(u=>this._parseCondition(u)).join(" ");return`{{#if ${i.length>1?`(${o} ${r})`:r}}}`}else return`{{#if ${this._parseCondition(n)}}}`}_parseCondition(e){if(!e)return"";const s=e,n=e;if(n.statements&&n.logicalOperator==="and"||n.logicalOperator==="or"){const{statements:a}=n,i=n.logicalOperator,o=n.statements.map(r=>this._parseCondition(r)).join(" ");return a.length>1?`(${i} ${o})`:o}else{const a=s.operator,i=this.getHelperId(a),o=this._parseValue(s.left),r=this._parseValue(s.right);return this.getExpressionStr(i,o,r)}}getExpressionStr(e,s,n){return $[e]?e==="isTruthy"?s:e==="isFalsy"?`!${s}`:`${e} ${s}`:`(${e} ${s} ${n})`}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class B{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const s=this.parse(e);return this.astToGrapesJS(s)}parse(e){try{return p.parse(e)}catch(s){if(s instanceof Error&&s.message.includes("Parse error")){const n=s.message.match(/line (\d+)/),a=n?parseInt(n[1]):0,i=s.message.match(/column (\d+)/),o=i?parseInt(i[1]):0;throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`)}throw s}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"ContentStatement":return this.handleContentStatement(e);case"MustacheStatement":return this.handleMustacheStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"PartialStatement":return this.handlePartialStatement(e);case"CommentStatement":return this.handleCommentStatement(e);case"ElementNode":return this.handleElementNode(e);case"TextNode":return this.handleTextNode(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`,e.loc),""}}handleProgram(e){let s="";if(e.body)for(const n of e.body)s+=this.astToGrapesJS(n);return s}handleContentStatement(e){return e.value||""}handleMustacheStatement(e,s={}){const n=this.getExpressionString(e.path),a={...s};return this.collectionStack.length>0?this.processPathWithCollectionContext(n,a):a.path=n,`<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`}processPathWithCollectionContext(e,s){e.startsWith("@")?this.handleDirectCollectionReference(e,s):this.handleRelativePathReference(e,s)}handleDirectCollectionReference(e,s){if(this.isSpecialIterationVariable(e)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],e,s);return}const[n,...a]=e.substring(1).split("/"),i=a.join(".");this.collectionStack.includes(n)?this.setCurrentItemResolver(n,i,s):this.handleParentReferenceFallback(e,s)}isSpecialIterationVariable(e){return["index","@index","key","@key"].includes(e)}setSpecialVariableResolver(e,s,n){n.collectionId=e;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};n.variableType=a[s]}setCurrentItemResolver(e,s,n){n.collectionId=e,n.variableType="currentItem",s&&(n.path=s)}handleRelativePathReference(e,s){const n=P(e),{parentLevel:a,remainingPathParts:i}=this.calculateParentLevel(n),o=i.join("."),r=this.collectionStack.length-1-a;r>=0&&r<this.collectionStack.length?this.resolveRelativePath(o,r,s):s.path=i.join(".")}calculateParentLevel(e){const s=this.collectionStack.findLastIndex(i=>i===e[0]);if(s!==-1)return{parentLevel:this.collectionStack.length-1-s,remainingPathParts:e.slice(1)};let n=0;const a=[...e];for(;a[0]==="..";)n++,a.shift();return{parentLevel:n,remainingPathParts:a}}resolveRelativePath(e,s,n){const a=this.collectionStack[s];n.collectionId=a,n.variableType="currentItem",e!=="this"&&(n.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,s){const n=P(e),{parentLevel:a,remainingPathParts:i}=this.calculateParentLevel(n),o=i.join("."),r=this.collectionStack.length-1-a;r>=0&&r<this.collectionStack.length?this.resolveRelativePath(o,r,s):s.path=i.join(".")}handleBlockStatement(e){const s=e.path.original;switch(s){case"if":case"unless":return this.handleConditionalBlock(e,s);case"each":return this.handleEachBlock(e);default:return this.addMessage("warning",`Unsupported block helper: ${s}`,e.loc),this.handleGenericBlock(e)}}handleConditionalBlock(e,s){const i={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:s==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(e.program),r=e.inverse?this.handleProgram(e.inverse):"";return`
|
|
2
|
-
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:
|
|
1
|
+
(function(p,g){typeof exports=="object"&&typeof module<"u"?module.exports=g(require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["handlebars/dist/cjs/handlebars"],g):(p=typeof globalThis<"u"?globalThis:p||self,p.StudioSdkPlugins_dataSourceHandlebars=g(p.Handlebars))})(this,function(p){"use strict";const g="app.grapesjs.com",P="app-stage.grapesjs.com",m=[g,"app2.grapesjs.com",P,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],I="license:check:end",S=()=>typeof window<"u",T=({isDev:t,isStage:e,isPlatform:n})=>`${t?"":`https://${e?P:g}`}/${n?"platform-api":"api"}`,k=()=>{if(!S())return"";const{hostname:t}=window.location;if(t)return t;try{return window.parent.location.hostname||""}catch{return""}},A=()=>{const t=k();return!!t&&(m.includes(t)||m.some(e=>t.endsWith(e)))};async function N({path:t,baseApiUrl:e,method:n="GET",headers:s={},params:a,body:r}){const i=`${e||T({isDev:!1,isStage:!1})}${t}`,c={method:n,headers:{"Content-Type":"application/json",...s}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",h=u?`?${u}`:"",l=await fetch(`${i}${h}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var d=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(d||{}),f=(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))(f||{});const x={[d.free]:0,[d.startup]:10,[d.business]:20,[d.enterprise]:30};function O(t){const e=t;return e.init=n=>s=>t(s,n),e}const R=t=>O(t);async function _({editor:t,plan:e,pluginName:n,licenseKey:s,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",n,"Reason:",l),r()},u=(l={})=>{var E;const{error:v,sdkLicense:W}=l,y=(E=l.plan)==null?void 0:E.category;if(!(W||l.license)||v)c(v||"Invalid license");else if(y){const V=x[e],F=x[y];V>F&&c({pluginRequiredPlan:e,licensePlan:y})}};t.Commands.has(f.settings)&&(i=t.runCommand(f.settings),o=(i==null?void 0:i.baseUrl)||"");const h=l=>{a==null||a(l),l&&u(l)};if(!i){t.onReady(async()=>{if(!A())if(s){const l=await w({licenseKey:s,pluginName:n,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=L(i);h(l);return}t.on(I,l=>h(l))}const L=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function w(t){const{licenseKey:e,pluginName:n,baseApiUrl:s}=t;try{return(await N({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const D=(t,e)=>(t.config.optsHtml={...t.config.optsHtml,exporter:e},()=>{t.config.optsHtml.exporter=void 0}),G=(t,e)=>{const n=a=>{const{input:r}=a,{contains:o}=e;(!o||r.includes(o))&&(a.input=e.importer.import(r))},s=t.Parser.events.htmlBefore;return t.on(s,n),()=>{t.off(s,n)}},$={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},M={...$,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class B{getHelperId(e){return M[e]||e}getFullPath({collectionId:e,path:n}){let s=n;return e&&(s=[this._sanitizeVariableName(e),n].filter(Boolean).join(".")),s||""}getVariableSyntax({dataResolver:e}){const{defaultValue:n}=e,s=this.getFullPath(e);return n?`{{#if ${s}}}{{{${s}}}}{{else}}${n}{{/if}}`:`{{{${s}}}}`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:n,dataSource:s}=e,a=s==null?void 0:s.path;let r="";if(e.startIndex!==void 0||e.endIndex!==void 0){const u=e.startIndex??0,h=e.endIndex!==void 0?e.endIndex:"";h!==""?r=` (slice ${a} ${u} ${h})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(n)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:e}){const n=e.condition;if(!n)return"";const s=n,a=n;if(a.statements&&a.logicalOperator==="and"||a.logicalOperator==="or"){const{statements:r}=a,o=a.logicalOperator,i=r.map(u=>this._parseCondition(u)).join(" ");return`{{#if ${r.length>1?`(${o} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(s)}}}`}_parseCondition(e){if(!e)return"";const n=e,s=e;if(s.statements&&s.logicalOperator==="and"||s.logicalOperator==="or"){const{statements:a}=s,r=s.logicalOperator,o=s.statements.map(i=>this._parseCondition(i)).join(" ");return a.length>1?`(${r} ${o})`:o}else{const a=n.operator,r=this.getHelperId(a),o=this._parseValue(n.left),i=this._parseValue(n.right);return this.getExpressionStr(r,o,i)}}getExpressionStr(e,n,s){return $[e]?e==="isTruthy"?n:e==="isFalsy"?`!${n}`:`${e} ${n}`:`(${e} ${n} ${s})`}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class j{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const n=this.parse(e);return this.astToGrapesJS(n)}parse(e){try{return p.parse(e)}catch(n){if(n instanceof Error&&n.message.includes("Parse error")){const s=n.message.match(/line (\d+)/),a=s?parseInt(s[1]):0,r=n.message.match(/column (\d+)/),o=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${n.message}`)}throw n}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"ContentStatement":return this.handleContentStatement(e);case"MustacheStatement":return this.handleMustacheStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"PartialStatement":return this.handlePartialStatement(e);case"CommentStatement":return this.handleCommentStatement(e);case"ElementNode":return this.handleElementNode(e);case"TextNode":return this.handleTextNode(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`,e.loc),""}}handleProgram(e){let n="";if(e.body)for(const s of e.body)n+=this.astToGrapesJS(s);return n}handleContentStatement(e){return e.value||""}handleMustacheStatement(e,n={}){const s=this.getExpressionString(e.path),a={...n};return this.collectionStack.length>0?this.processPathWithCollectionContext(s,a):a.path=s,`<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`}processPathWithCollectionContext(e,n){e.startsWith("@")?this.handleDirectCollectionReference(e,n):this.handleRelativePathReference(e,n)}handleDirectCollectionReference(e,n){if(this.isSpecialIterationVariable(e)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],e,n);return}const[s,...a]=e.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(s)?this.setCurrentItemResolver(s,r,n):this.handleParentReferenceFallback(e,n)}isSpecialIterationVariable(e){return["index","@index","key","@key"].includes(e)}setSpecialVariableResolver(e,n,s){s.collectionId=e;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};s.variableType=a[n]}setCurrentItemResolver(e,n,s){s.collectionId=e,s.variableType="currentItem",n&&(s.path=n)}handleRelativePathReference(e,n){const s=b(e),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(s),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,n):n.path=r.join(".")}calculateParentLevel(e){const n=this.collectionStack.findLastIndex(r=>r===e[0]);if(n!==-1)return{parentLevel:this.collectionStack.length-1-n,remainingPathParts:e.slice(1)};let s=0;const a=[...e];for(;a[0]==="..";)s++,a.shift();return{parentLevel:s,remainingPathParts:a}}resolveRelativePath(e,n,s){const a=this.collectionStack[n];s.collectionId=a,s.variableType="currentItem",e!=="this"&&(s.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,n){const s=b(e),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(s),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,n):n.path=r.join(".")}handleBlockStatement(e){const n=e.path.original;switch(n){case"if":case"unless":return this.handleConditionalBlock(e,n);case"each":return this.handleEachBlock(e);default:return this.addMessage("warning",`Unsupported block helper: ${n}`,e.loc),this.handleGenericBlock(e)}}handleConditionalBlock(e,n){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:n==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(e.program),i=e.inverse?this.handleProgram(e.inverse):"";return`
|
|
2
|
+
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
|
|
3
3
|
<data-condition-true-content>${o}</data-condition-true-content>
|
|
4
|
-
<data-condition-false-content>${
|
|
4
|
+
<data-condition-false-content>${i}</data-condition-false-content>
|
|
5
5
|
</data-condition>
|
|
6
|
-
`}handleEachBlock(e){var
|
|
7
|
-
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:
|
|
6
|
+
`}handleEachBlock(e){var r,o,i;const n=this.getExpressionString(e.params[0]);let s;e.params.length>=3&&e.params[1]==="as"&&((r=e.params[2])==null?void 0:r.type)==="PathExpression"?s=e.params[2].original:(i=(o=e.program)==null?void 0:o.blockParams)!=null&&i.length?s=e.program.blockParams[0]:s=`collection-${Math.random().toString(36).substring(2,10)}`,this.collectionStack.push(s);const a=this.handleProgram(e.program);return this.collectionStack.pop(),`
|
|
7
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:n},collectionId:s})}'>
|
|
8
8
|
<data-collection-item>${a}</data-collection-item>
|
|
9
9
|
</data-collection>
|
|
10
|
-
`}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let
|
|
10
|
+
`}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let n="";if(e.attributes)for(const a of e.attributes)a.value.type==="TextNode"?n+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,e.loc),n+=` ${a.name}="${this.getExpressionString(a.value)}"`);let s="";if(e.children)for(const a of e.children)s+=this.astToGrapesJS(a);return`<${e.tag}${n}>${s}</${e.tag}>`}handleTextNode(e){return e.chars||""}handlePartialStatement(e){return this.addMessage("warning",`Partials are not fully supported: ${e.name.original}`,e.loc),`{{> ${e.name.original}}}`}handleGenericBlock(e){const n=this.handleProgram(e.program);return`<!-- Unsupported block: ${e.path.original} -->${n}`}getExpressionString(e){return e.type==="PathExpression"?e.original:e.type==="StringLiteral"?e.value:e.type==="NumberLiteral"?e.value.toString():e.type==="BooleanLiteral"?e.value?"true":"false":e.type==="SubExpression"?this.getExpressionString(e.params[0]):e.type==="Hash"?`{${e.pairs.map(s=>`${s.key}=${this.getExpressionString(s.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${e.type}`,e.loc),"")}addMessage(e,n,s){this.messages.push({type:e,message:n,location:s?{line:s.start.line,column:s.start.column}:void 0})}}const b=t=>{if(t==null||t==="")return[];if(t===".")return["this"];if(t===".."||t==="../")return[".."];if(t.startsWith("../")){const o=t.substring(3);return["..",...b(o)]}const e=[];let n=0,s=t.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const h=c!==void 0?c:u||"";return e[n]=h,`__HANDLEBARS_PLACEHOLDER_${n++}__`});s=s.replace(/\//g,".");const a=s.split("."),r=[];for(const o of a){const i=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);if(i){const c=parseInt(i[1],10);r.push(e[c])}else o!==""&&r.push(o)}return r},U="dataSourceHandlebars",H=d.startup;return R(function(t,e={}){const n=D(t,new B),s=G(t,{contains:"{{",importer:new j});_({editor:t,licenseKey:e.licenseKey,plan:H,pluginName:U,cleanup:()=>{n(),s()}})})});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";const A="app.grapesjs.com",k="app-stage.grapesjs.com",R="app2.grapesjs.com",_="app-stage2.grapesjs.com",x=[A,R,k,_,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:end",G=()=>typeof window<"u",N=({isDev:e,isStage:
|
|
1
|
+
"use strict";const A="app.grapesjs.com",k="app-stage.grapesjs.com",R="app2.grapesjs.com",_="app-stage2.grapesjs.com",x=[A,R,k,_,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],$="license:check:end",G=()=>typeof window<"u",N=({isDev:e,isStage:s,isPlatform:r})=>`${e?"":`https://${s?k:A}`}/${r?"platform-api":"api"}`,B=()=>{if(!G())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},m=()=>{const e=B();return!!e&&(x.includes(e)||x.some(s=>e.endsWith(s)))};async function M({path:e,baseApiUrl:s,method:r="GET",headers:n={},params:c,body:i}){const a=`${s||N({isDev:!1,isStage:!1})}${e}`,g={method:r,headers:{"Content-Type":"application/json",...n}};i&&(g.body=JSON.stringify(i));const p=c?new URLSearchParams(c).toString():"",d=p?`?${p}`:"",o=await fetch(`${a}${d}`,g);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var W=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(W||{}),T=(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))(T||{});const O={[W.free]:0,[W.startup]:10,[W.business]:20,[W.enterprise]:30};function I(e){const s=e;return s.init=r=>n=>e(n,r),s}const U=e=>I(e);async function q({editor:e,plan:s,pluginName:r,licenseKey:n,onLicenseCheckResponse:c,cleanup:i}){let u="",a;const g=o=>{console.warn("Cleanup plugin:",r,"Reason:",o),i()},p=(o={})=>{var b;const{error:v,sdkLicense:L}=o,l=(b=o.plan)==null?void 0:b.category;if(!(L||o.license)||v)g(v||"Invalid license");else if(l){const P=O[s],w=O[l];P>w&&g({pluginRequiredPlan:s,licensePlan:l})}};e.Commands.has(T.settings)&&(a=e.runCommand(T.settings),u=(a==null?void 0:a.baseUrl)||"");const d=o=>{c==null||c(o),o&&p(o)};if(!a){e.onReady(async()=>{if(!m())if(n){const o=await F({licenseKey:n,pluginName:r,baseApiUrl:u});d(o)}else g("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const o=X(a);d(o);return}e.on($,o=>d(o))}const X=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function F(e){const{licenseKey:s,pluginName:r,baseApiUrl:n}=e;try{return(await M({baseApiUrl:n,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}const j=(...e)=>e.map(s=>`[data-gjs-type="${s}"]`).join(","),z="dialogComponent",H=function(e,s={}){const{Blocks:r,Components:n}=e,{licenseKey:c}=s,i="gjs-plg-dialog",u="gjs-plg-dialog-overlay",a="gjs-plg-dialog-content",g="gjs-plg-dialog-close",p="gjs-plg-dialog-title",d="gjs-plg-dialog-body",o="gjs-plg-dialog-description",v="gjs-plg-dialog-placeholder";r.add(i,{label:"Dialog",media:`
|
|
2
2
|
<svg viewBox="0 0 24 24">
|
|
3
3
|
<path d="M4 4h16v10H8l-4 4V4z"></path>
|
|
4
4
|
</svg>
|
|
5
|
-
`,category:"Extra",content:{type:i},activate:!0,...
|
|
5
|
+
`,category:"Extra",content:{type:i},activate:!0,...s.block}),n.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:u},{type:v}],draggable:j("wrapper"),droppable:j(i),styles:`
|
|
6
6
|
.${i} {
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 1;
|
|
9
9
|
}
|
|
10
|
-
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(l){var t;(t=l.getSelected())==null||t.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(l){const t=this;function b(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),h=t.querySelector('[data-type-role="gjs-plg-dialog-close"]');function E(){f.style.display="none"}y?(t._onCloseWhenPressingX=E,h.addEventListener("click",t._onCloseWhenPressingX)):(h.removeEventListener("click",t._onCloseWhenPressingX),t._onCloseWhenPressingX=null)}function P(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function h(E){E.key==="Escape"&&(f.style.display="none")}y?(t._onCloseWhenPressingEsc=h,t.addEventListener("keydown",t._onCloseWhenPressingEsc)):(t.removeEventListener("keydown",t._onCloseWhenPressingEsc),t._onCloseWhenPressingEsc=null)}function
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(l){var t;(t=l.getSelected())==null||t.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(l){const t=this;function b(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),h=t.querySelector('[data-type-role="gjs-plg-dialog-close"]');function E(){f.style.display="none"}y?(t._onCloseWhenPressingX=E,h.addEventListener("click",t._onCloseWhenPressingX)):(h.removeEventListener("click",t._onCloseWhenPressingX),t._onCloseWhenPressingX=null)}function P(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function h(E){E.key==="Escape"&&(f.style.display="none")}y?(t._onCloseWhenPressingEsc=h,t.addEventListener("keydown",t._onCloseWhenPressingEsc)):(t.removeEventListener("keydown",t._onCloseWhenPressingEsc),t._onCloseWhenPressingEsc=null)}function w(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function h(){f.style.display="flex"}y?(t._onOpenWhenLeavingWindow=h,document.addEventListener("mouseleave",t._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",t._onOpenWhenLeavingWindow),t._onOpenWhenLeavingWindow=null)}function D(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function h(){const E=document.documentElement.scrollTop;y&&E>=Number(y)&&(f.style.display="flex")}y?(t._onOpenWhenScrollingToLevel=h,document.addEventListener("scroll",t._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",t._onOpenWhenScrollingToLevel),t._onOpenWhenScrollingToLevel=null)}b(l.closeWhenPressingX),P(l.closeWhenPressingEsc),w(l.openWhenLeavingWindow),D(l.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const t=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');t.style.display="flex"})}},view:{onActive(){const l=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');l.style.display="flex"}}}),n.addType(u,{model:{defaults:{tagName:"div",attributes:{class:u,"data-type-role":u},components:{type:a},droppable:!1,draggable:!1,styles:`
|
|
11
11
|
.${u} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
justify-content: center;
|
|
20
20
|
background-color: rgba(0, 0, 0, 0.5);
|
|
21
21
|
}
|
|
22
|
-
`}}}),
|
|
22
|
+
`}}}),n.addType(a,{model:{defaults:{tagName:"div",attributes:{class:a,"data-type-role":a},components:[{type:g},{type:p},{type:d}],droppable:!1,draggable:!1,styles:`
|
|
23
23
|
.${a} {
|
|
24
24
|
position: relative;
|
|
25
25
|
background-color: #fff;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
height: 600px;
|
|
31
31
|
box-sizing: border-box;
|
|
32
32
|
}
|
|
33
|
-
`}}}),
|
|
33
|
+
`}}}),n.addType(g,{model:{defaults:{tagName:"button",attributes:{class:g,"data-type-role":g},components:"×",droppable:!1,draggable:!1,styles:`
|
|
34
34
|
.${g} {
|
|
35
35
|
position: absolute;
|
|
36
36
|
top: 10px;
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
font-size: 20px;
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
}
|
|
45
|
-
`}}}),
|
|
45
|
+
`}}}),n.addType(p,{model:{defaults:{tagName:"h2",attributes:{class:p,"data-type-role":p},components:"Dialog Title",editable:!0,droppable:!1,draggable:!1,styles:`
|
|
46
46
|
.${p} {
|
|
47
47
|
margin: 0;
|
|
48
48
|
padding: 0 40px 20px 0;
|
|
49
49
|
}
|
|
50
|
-
`}}}),
|
|
50
|
+
`}}}),n.addType(d,{model:{defaults:{tagName:"div",attributes:{class:d,"data-type-role":d},components:[{type:o}],styles:`
|
|
51
51
|
.${d} {
|
|
52
52
|
height: 90%;
|
|
53
53
|
overflow: auto;
|
|
54
54
|
}
|
|
55
|
-
`}}}),
|
|
55
|
+
`}}}),n.addType(o,{model:{defaults:{tagName:"p",attributes:{class:o,"data-type-role":o},components:"This is a customizable dialog!",editable:!0,styles:`
|
|
56
56
|
.${o} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),
|
|
59
|
+
`}}}),n.addType(v,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:v,"data-type-role":v},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:l,el:t}=this,b="core:preview",P=l.Commands.events;this.listenTo(l,`${P.runCommand}${b}`,()=>{t.style.display="none"}),this.listenTo(l,`${P.stopCommand}${b}`,()=>{t.style.display=""})}}}),q({editor:e,licenseKey:c,plan:W.startup,pluginName:z,cleanup:()=>{r.remove(i),n.removeType(i)}})},K=U(H);module.exports=K;
|