@grapesjs/studio-sdk-plugins 1.0.38 → 1.0.39-rc.1
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 +5 -5
- package/dist/accordionComponent/index.es.js +70 -67
- package/dist/accordionComponent/index.js +39 -0
- package/dist/accordionComponent/index.umd.js +4 -4
- package/dist/aiChat/components/AiChatHeader.d.ts +4 -5
- package/dist/aiChat/components/AiChatInput/index.d.ts +4 -5
- package/dist/aiChat/components/AiChatMessage.d.ts +7 -8
- package/dist/aiChat/components/index.d.ts +1 -1
- package/dist/aiChat/components/utils.d.ts +1 -1
- package/dist/aiChat/index.cjs.js +10 -376
- package/dist/aiChat/index.es.js +4569 -28851
- package/dist/aiChat/index.js +10 -376
- package/dist/aiChat/index.umd.js +11 -377
- package/dist/aiChat/server/index.cjs.d.ts +0 -1
- package/dist/aiChat/server/index.cjs.js +45 -45
- package/dist/aiChat/server/index.d.ts +0 -1
- package/dist/aiChat/server/index.es.d.ts +0 -1
- package/dist/aiChat/server/index.es.js +371 -427
- package/dist/aiChat/server/index.js +45 -45
- package/dist/aiChat/server/index.umd.js +41 -41
- package/dist/aiChat/server/stream.test.d.ts +1 -0
- package/dist/aiChat/types.d.ts +18 -4
- package/dist/aiChat/typesSchema.d.ts +13 -0
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +49 -46
- package/dist/animationComponent/index.js +519 -0
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +115 -112
- package/dist/canvasAbsoluteMode/index.js +1 -0
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +71 -68
- package/dist/canvasEmptyState/index.js +1 -0
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +3 -3
- package/dist/canvasFullSize/index.es.js +69 -66
- package/dist/canvasFullSize/index.js +10 -0
- package/dist/canvasFullSize/index.umd.js +4 -4
- package/dist/canvasGridMode/index.cjs.js +7 -7
- package/dist/canvasGridMode/index.es.js +142 -139
- package/dist/canvasGridMode/index.js +26 -0
- package/dist/canvasGridMode/index.umd.js +7 -7
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +78 -75
- package/dist/canvasScreenshot/index.js +1 -0
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/EjsExporter.d.ts +1 -1
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +40 -37
- package/dist/dataSourceEjs/index.js +21 -0
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
- package/dist/dataSourceHandlebars/constants.d.ts +1 -1
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +58 -55
- package/dist/dataSourceHandlebars/index.js +10 -0
- package/dist/dataSourceHandlebars/index.umd.js +2 -2
- package/dist/dialogComponent/index.cjs.js +11 -11
- package/dist/dialogComponent/index.es.js +72 -69
- package/dist/dialogComponent/index.js +59 -0
- package/dist/dialogComponent/index.umd.js +11 -11
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +151 -142
- package/dist/flexComponent/index.js +33 -0
- package/dist/flexComponent/index.umd.js +8 -8
- package/dist/flexComponent/typesSchema.d.ts +1 -1
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +93 -90
- package/dist/fsLightboxComponent/index.js +6 -0
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +112 -109
- package/dist/googleFontsAssetProvider/index.js +1 -0
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +80 -77
- package/dist/iconifyComponent/index.js +3 -0
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +970 -82
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +7422 -6145
- package/dist/index.umd.js +975 -87
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +95 -92
- package/dist/layoutSidebarButtons/index.js +1 -0
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +164 -161
- package/dist/lightGalleryComponent/index.js +1 -0
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/lightGalleryComponent/utils.d.ts +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +60 -57
- package/dist/linkImageComponent/index.js +12 -0
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +4 -4
- package/dist/listPagesComponent/index.es.js +57 -54
- package/dist/listPagesComponent/index.js +11 -0
- package/dist/listPagesComponent/index.umd.js +4 -4
- package/dist/listPagesComponent/utils.d.ts +1 -1
- package/dist/presetBlockLibrary/blocks.d.ts +6 -0
- package/dist/presetBlockLibrary/blocks.test.d.ts +2 -0
- package/dist/presetBlockLibrary/emailBlocks.d.ts +53 -0
- package/dist/presetBlockLibrary/index.cjs.d.ts +3 -0
- package/dist/presetBlockLibrary/index.cjs.js +889 -0
- package/dist/presetBlockLibrary/index.d.ts +3 -0
- package/dist/presetBlockLibrary/index.es.d.ts +3 -0
- package/dist/presetBlockLibrary/index.es.js +1408 -0
- package/dist/presetBlockLibrary/index.js +889 -0
- package/dist/presetBlockLibrary/index.test.d.ts +1 -0
- package/dist/presetBlockLibrary/index.umd.js +889 -0
- package/dist/presetBlockLibrary/shared.d.ts +3 -0
- package/dist/presetBlockLibrary/types.d.ts +24 -0
- package/dist/presetBlockLibrary/typesSchema.d.ts +47 -0
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +133 -130
- package/dist/presetPrintable/index.js +32 -0
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +8 -8
- package/dist/prosemirror/index.es.js +552 -549
- package/dist/prosemirror/index.js +10 -0
- package/dist/prosemirror/index.umd.js +9 -9
- package/dist/prosemirror/toolbar.d.ts +2 -2
- package/dist/prosemirror/types.d.ts +5 -5
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +137 -134
- 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 -71
- package/dist/rteTinyMce/index.js +104 -0
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +91 -88
- package/dist/shapeDividerComponent/index.js +97 -0
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +7 -7
- package/dist/swiperComponent/index.es.js +95 -92
- package/dist/swiperComponent/index.js +45 -0
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +181 -178
- package/dist/tableComponent/index.js +1 -0
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/tableComponent/types.d.ts +3 -3
- package/dist/types.d.ts +14 -14
- package/dist/utils.d.ts +3 -2
- package/dist/utilsDataSources.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +90 -87
- package/dist/youtubeAssetProvider/index.js +1 -0
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +182 -34
- package/dist/aiChat/server/models.d.ts +0 -15
|
@@ -1,10 +1,10 @@
|
|
|
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.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))(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`
|
|
1
|
+
"use strict";const k=require("handlebars/dist/cjs/handlebars.js"),x="app.grapesjs.com",$="app-stage.grapesjs.com",A="app2.grapesjs.com",L="app-stage2.grapesjs.com",b=[x,A,$,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],N="license:check:end",_=()=>typeof window<"u",R=({isDev:e,isStage:t,isPlatform:n})=>`${e?"":`https://${t?$:x}`}/${n?"platform-api":"api"}`,O=()=>{if(!_())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},w=()=>{const e=O();return!!e&&(b.includes(e)||b.some(t=>e.endsWith(t)))};async function D({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:a,body:r}){const i=`${t||R({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",p=u?`?${u}`:"",l=await fetch(`${i}${p}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),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.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))(d||{});const m={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function B(e,t){const n=e;return n.init=s=>{const a=r=>e(r,s);return a.__gjsPluginId=t,a},n}const G=(e,t)=>B(e,t);async function M({editor:e,plan:t,pluginName:n,licenseKey:s,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",n,"Reason:",l),r(e,n)},u=(l={})=>{var P;const{error:y,sdkLicense:I}=l,g=(P=l.plan)==null?void 0:P.category;if(!(I||l.license)||y)c(y||"Invalid license");else if(g){const T=m[t],S=m[g];T>S&&c({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(d.settings)&&(i=e.runCommand(d.settings),o=(i==null?void 0:i.baseUrl)||"");const p=l=>{a==null||a(l),l&&u(l)};if(!i){e.onReady(async()=>{if(!w())if(s){const l=await U({licenseKey:s,pluginName:n,baseApiUrl:o});p(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=j(i);p(l);return}e.on(N,l=>p(l))}const j=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function U(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await D({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const H=(e,t)=>(e.config.optsHtml={...e.config.optsHtml,exporter:t},()=>{e.config.optsHtml.exporter=void 0}),W=(e,t)=>{const n=a=>{const{input:r}=a,{contains:o}=t;(!o||r.includes(o))&&(a.input=t.importer.import(r))},s=e.Parser.events.htmlBefore;return e.on(s,n),()=>{e.off(s,n)}},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"},V={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},F={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},C={...v,...V,...F};class q{getHelperId(t){return C[t]||t}getFullPath({collectionId:t,path:n}){let s=n;return t&&(s=[this._sanitizeVariableName(t),n].filter(Boolean).join(".")),s||""}getVariableSyntax({dataResolver:t}){const{defaultValue:n}=t,s=this.getFullPath(t);return n?`{{#if ${s}}}{{{${s}}}}{{else}}${n}{{/if}}`:`{{{${s}}}}`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:n,dataSource:s}=t,a=s==null?void 0:s.path;let r="";if(t.startIndex!==void 0||t.endIndex!==void 0){const u=t.startIndex??0,p=t.endIndex!==void 0?t.endIndex:"";p!==""?r=` (slice ${a} ${u} ${p})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(n)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:t}){const n=t.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(t){if(!t)return"";const n=t,s=t;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(t,n,s){return v[t]?t==="isTruthy"?n:t==="isFalsy"?`!${n}`:`${t} ${n}`:`(${t} ${n} ${s})`}_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 J{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];const n=this.parse(t);return this.astToGrapesJS(n)}parse(t){try{return k.parse(t)}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(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 n="";if(t.body)for(const s of t.body)n+=this.astToGrapesJS(s);return n}handleContentStatement(t){return t.value||""}handleMustacheStatement(t,n={}){const s=this.getExpressionString(t.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(t,n){t.startsWith("@")?this.handleDirectCollectionReference(t,n):this.handleRelativePathReference(t,n)}handleDirectCollectionReference(t,n){if(this.isSpecialIterationVariable(t)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],t,n);return}const[s,...a]=t.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(s)?this.setCurrentItemResolver(s,r,n):this.handleParentReferenceFallback(t,n)}isSpecialIterationVariable(t){return["index","@index","key","@key"].includes(t)}setSpecialVariableResolver(t,n,s){s.collectionId=t;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};s.variableType=a[n]}setCurrentItemResolver(t,n,s){s.collectionId=t,s.variableType="currentItem",n&&(s.path=n)}handleRelativePathReference(t,n){const s=f(t),{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(t){const n=this.collectionStack.findLastIndex(r=>r===t[0]);if(n!==-1)return{parentLevel:this.collectionStack.length-1-n,remainingPathParts:t.slice(1)};let s=0;const a=[...t];for(;a[0]==="..";)s++,a.shift();return{parentLevel:s,remainingPathParts:a}}resolveRelativePath(t,n,s){const a=this.collectionStack[n];s.collectionId=a,s.variableType="currentItem",t!=="this"&&(s.path=t.startsWith("this.")?t.split(".").slice(1).join("."):t)}handleParentReferenceFallback(t,n){const s=f(t),{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(t){const n=t.path.original;switch(n){case"if":case"unless":return this.handleConditionalBlock(t,n);case"each":return this.handleEachBlock(t);default:return this.addMessage("warning",`Unsupported block helper: ${n}`,t.loc),this.handleGenericBlock(t)}}handleConditionalBlock(t,n){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(t.params[0])},operator:n==="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>
|
|
5
5
|
</data-condition>
|
|
6
|
-
`}handleEachBlock(t){var r,o,i;const
|
|
7
|
-
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:
|
|
6
|
+
`}handleEachBlock(t){var r,o,i;const n=this.getExpressionString(t.params[0]);let s;t.params.length>=3&&t.params[1]==="as"&&((r=t.params[2])==null?void 0:r.type)==="PathExpression"?s=t.params[2].original:(i=(o=t.program)==null?void 0:o.blockParams)!=null&&i.length?s=t.program.blockParams[0]:s=`collection-${Math.random().toString(36).substring(2,10)}`,this.collectionStack.push(s);const a=this.handleProgram(t.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(t){return`<!--${t.value}-->`}handleElementNode(t){let
|
|
10
|
+
`}handleCommentStatement(t){return`<!--${t.value}-->`}handleElementNode(t){let n="";if(t.attributes)for(const a of t.attributes)a.value.type==="TextNode"?n+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,t.loc),n+=` ${a.name}="${this.getExpressionString(a.value)}"`);let s="";if(t.children)for(const a of t.children)s+=this.astToGrapesJS(a);return`<${t.tag}${n}>${s}</${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 n=this.handleProgram(t.program);return`<!-- Unsupported block: ${t.path.original} -->${n}`}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(s=>`${s.key}=${this.getExpressionString(s.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${t.type}`,t.loc),"")}addMessage(t,n,s){this.messages.push({type:t,message:n,location:s?{line:s.start.line,column:s.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 n=0,s=e.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const p=c!==void 0?c:u||"";return t[n]=p,`__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(t[c])}else o!==""&&r.push(o)}return r},E="dataSourceHandlebars",z=h.startup,K=function(e,t={}){const n=H(e,new q),s=W(e,{contains:"{{",importer:new J});M({editor:e,licenseKey:t.licenseKey,plan:z,pluginName:E,cleanup:()=>{n(),s()}})},Y=G(K,E);module.exports=Y;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
const x = "app.grapesjs.com", $ = "app-stage.grapesjs.com",
|
|
1
|
+
import k from "handlebars/dist/cjs/handlebars.js";
|
|
2
|
+
const x = "app.grapesjs.com", $ = "app-stage.grapesjs.com", A = "app2.grapesjs.com", L = "app-stage2.grapesjs.com", b = [
|
|
3
3
|
x,
|
|
4
|
-
k,
|
|
5
|
-
$,
|
|
6
4
|
A,
|
|
5
|
+
$,
|
|
6
|
+
L,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
@@ -16,12 +16,12 @@ const x = "app.grapesjs.com", $ = "app-stage.grapesjs.com", k = "app2.grapesjs.c
|
|
|
16
16
|
// For Claude mcp app
|
|
17
17
|
".web-sandbox.oaiusercontent.com"
|
|
18
18
|
// For OpenAI mcp app
|
|
19
|
-
],
|
|
19
|
+
], N = "license:check:end", _ = () => typeof window < "u", R = ({
|
|
20
20
|
isDev: e,
|
|
21
21
|
isStage: t,
|
|
22
22
|
isPlatform: n
|
|
23
23
|
}) => `${e ? "" : `https://${t ? $ : x}`}/${n ? "platform-api" : "api"}`, O = () => {
|
|
24
|
-
if (!
|
|
24
|
+
if (!_()) return "";
|
|
25
25
|
const { hostname: e } = window.location;
|
|
26
26
|
if (e) return e;
|
|
27
27
|
try {
|
|
@@ -29,11 +29,11 @@ const x = "app.grapesjs.com", $ = "app-stage.grapesjs.com", k = "app2.grapesjs.c
|
|
|
29
29
|
} catch {
|
|
30
30
|
return "";
|
|
31
31
|
}
|
|
32
|
-
},
|
|
32
|
+
}, w = () => {
|
|
33
33
|
const e = O();
|
|
34
|
-
return !!e && (
|
|
34
|
+
return !!e && (b.includes(e) || b.some((t) => e.endsWith(t)));
|
|
35
35
|
};
|
|
36
|
-
async function
|
|
36
|
+
async function D({
|
|
37
37
|
path: e,
|
|
38
38
|
baseApiUrl: t,
|
|
39
39
|
method: n = "GET",
|
|
@@ -49,23 +49,26 @@ async function w({
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
r && (c.body = JSON.stringify(r));
|
|
52
|
-
const u = a ? new URLSearchParams(a).toString() : "",
|
|
52
|
+
const u = a ? new URLSearchParams(a).toString() : "", p = u ? `?${u}` : "", l = await fetch(`${i}${p}`, c);
|
|
53
53
|
if (!l.ok)
|
|
54
54
|
throw new Error(`HTTP error! status: ${l.status}`);
|
|
55
55
|
return l.json();
|
|
56
56
|
}
|
|
57
|
-
var
|
|
57
|
+
var h = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(h || {}), d = /* @__PURE__ */ ((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))(d || {});
|
|
58
58
|
const m = {
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
59
|
+
[h.free]: 0,
|
|
60
|
+
[h.startup]: 10,
|
|
61
|
+
[h.business]: 20,
|
|
62
|
+
[h.enterprise]: 30
|
|
63
63
|
};
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
return
|
|
64
|
+
function B(e, t) {
|
|
65
|
+
const n = e;
|
|
66
|
+
return n.init = (s) => {
|
|
67
|
+
const a = (r) => e(r, s);
|
|
68
|
+
return a.__gjsPluginId = t, a;
|
|
69
|
+
}, n;
|
|
67
70
|
}
|
|
68
|
-
const G = (e) => /* @__PURE__ */
|
|
71
|
+
const G = (e, t) => /* @__PURE__ */ B(e, t);
|
|
69
72
|
async function M({
|
|
70
73
|
editor: e,
|
|
71
74
|
plan: t,
|
|
@@ -76,49 +79,49 @@ async function M({
|
|
|
76
79
|
}) {
|
|
77
80
|
let o = "", i;
|
|
78
81
|
const c = (l) => {
|
|
79
|
-
console.warn("Cleanup plugin:", n, "Reason:", l), r();
|
|
82
|
+
console.warn("Cleanup plugin:", n, "Reason:", l), r(e, n);
|
|
80
83
|
}, u = (l = {}) => {
|
|
81
|
-
var
|
|
82
|
-
const { error: y, sdkLicense:
|
|
83
|
-
if (!(
|
|
84
|
+
var P;
|
|
85
|
+
const { error: y, sdkLicense: I } = l, g = (P = l.plan) == null ? void 0 : P.category;
|
|
86
|
+
if (!(I || l.license) || y)
|
|
84
87
|
c(y || "Invalid license");
|
|
85
88
|
else if (g) {
|
|
86
|
-
const
|
|
87
|
-
|
|
89
|
+
const T = m[t], S = m[g];
|
|
90
|
+
T > S && c({ pluginRequiredPlan: t, licensePlan: g });
|
|
88
91
|
}
|
|
89
92
|
};
|
|
90
93
|
e.Commands.has(d.settings) && (i = e.runCommand(d.settings), o = (i == null ? void 0 : i.baseUrl) || "");
|
|
91
|
-
const
|
|
94
|
+
const p = (l) => {
|
|
92
95
|
a == null || a(l), l && u(l);
|
|
93
96
|
};
|
|
94
97
|
if (!i) {
|
|
95
98
|
e.onReady(async () => {
|
|
96
|
-
if (!
|
|
99
|
+
if (!w())
|
|
97
100
|
if (s) {
|
|
98
|
-
const l = await
|
|
99
|
-
|
|
101
|
+
const l = await U({ licenseKey: s, pluginName: n, baseApiUrl: o });
|
|
102
|
+
p(l);
|
|
100
103
|
} else
|
|
101
104
|
c("The `licenseKey` option not provided");
|
|
102
105
|
});
|
|
103
106
|
return;
|
|
104
107
|
}
|
|
105
108
|
if (i.licensePlan || i.licenseError) {
|
|
106
|
-
const l =
|
|
107
|
-
|
|
109
|
+
const l = j(i);
|
|
110
|
+
p(l);
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
110
|
-
e.on(
|
|
113
|
+
e.on(N, (l) => p(l));
|
|
111
114
|
}
|
|
112
|
-
const
|
|
115
|
+
const j = (e) => ({
|
|
113
116
|
sdkLicense: e.license,
|
|
114
117
|
license: e.license,
|
|
115
118
|
error: e.licenseError,
|
|
116
119
|
plan: e.licensePlan
|
|
117
120
|
});
|
|
118
|
-
async function
|
|
121
|
+
async function U(e) {
|
|
119
122
|
const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
|
|
120
123
|
try {
|
|
121
|
-
return (await
|
|
124
|
+
return (await D({
|
|
122
125
|
baseApiUrl: s,
|
|
123
126
|
path: `/sdk/${t || "na"}`,
|
|
124
127
|
method: "POST",
|
|
@@ -131,12 +134,12 @@ async function j(e) {
|
|
|
131
134
|
return console.error("Error during SDK license check:", a), !1;
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
|
-
const
|
|
137
|
+
const H = (e, t) => (e.config.optsHtml = {
|
|
135
138
|
...e.config.optsHtml,
|
|
136
139
|
exporter: t
|
|
137
140
|
}, () => {
|
|
138
141
|
e.config.optsHtml.exporter = void 0;
|
|
139
|
-
}),
|
|
142
|
+
}), W = (e, t) => {
|
|
140
143
|
const n = (a) => {
|
|
141
144
|
const { input: r } = a, { contains: o } = t;
|
|
142
145
|
(!o || r.includes(o)) && (a.input = t.importer.import(r));
|
|
@@ -157,27 +160,27 @@ const U = (e, t) => (e.config.optsHtml = {
|
|
|
157
160
|
isNumber: "isNumber",
|
|
158
161
|
isBoolean: "isBoolean",
|
|
159
162
|
isDefaultValue: "isDefaultValue"
|
|
160
|
-
},
|
|
163
|
+
}, V = {
|
|
161
164
|
">": "numGt",
|
|
162
165
|
"<": "numLt",
|
|
163
166
|
">=": "numGte",
|
|
164
167
|
"<=": "numLte",
|
|
165
168
|
"=": "numEq",
|
|
166
169
|
"!=": "numNeq"
|
|
167
|
-
},
|
|
170
|
+
}, F = {
|
|
168
171
|
contains: "strContains",
|
|
169
172
|
startsWith: "strStartsWith",
|
|
170
173
|
endsWith: "strEndsWith",
|
|
171
174
|
equalsIgnoreCase: "strEqualsIgnoreCase",
|
|
172
175
|
trimEquals: "strTrimEquals"
|
|
173
|
-
},
|
|
176
|
+
}, C = {
|
|
174
177
|
...v,
|
|
175
|
-
...
|
|
176
|
-
...
|
|
178
|
+
...V,
|
|
179
|
+
...F
|
|
177
180
|
};
|
|
178
|
-
class
|
|
181
|
+
class q {
|
|
179
182
|
getHelperId(t) {
|
|
180
|
-
return
|
|
183
|
+
return C[t] || t;
|
|
181
184
|
}
|
|
182
185
|
getFullPath({ collectionId: t, path: n }) {
|
|
183
186
|
let s = n;
|
|
@@ -191,8 +194,8 @@ class C {
|
|
|
191
194
|
const { collectionId: n, dataSource: s } = t, a = s == null ? void 0 : s.path;
|
|
192
195
|
let r = "";
|
|
193
196
|
if (t.startIndex !== void 0 || t.endIndex !== void 0) {
|
|
194
|
-
const u = t.startIndex ?? 0,
|
|
195
|
-
|
|
197
|
+
const u = t.startIndex ?? 0, p = t.endIndex !== void 0 ? t.endIndex : "";
|
|
198
|
+
p !== "" ? r = ` (slice ${a} ${u} ${p})` : r = ` (slice ${a} ${u})`;
|
|
196
199
|
}
|
|
197
200
|
const i = ` as |${this._sanitizeVariableName(n)}|`;
|
|
198
201
|
return `{{#each ${r || a}${i}}}`;
|
|
@@ -237,7 +240,7 @@ class C {
|
|
|
237
240
|
return "{{/if}}";
|
|
238
241
|
}
|
|
239
242
|
}
|
|
240
|
-
class
|
|
243
|
+
class J {
|
|
241
244
|
constructor() {
|
|
242
245
|
this.messages = [], this.collectionStack = [];
|
|
243
246
|
}
|
|
@@ -248,7 +251,7 @@ class q {
|
|
|
248
251
|
}
|
|
249
252
|
parse(t) {
|
|
250
253
|
try {
|
|
251
|
-
return
|
|
254
|
+
return k.parse(t);
|
|
252
255
|
} catch (n) {
|
|
253
256
|
if (n instanceof Error && n.message.includes("Parse error")) {
|
|
254
257
|
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;
|
|
@@ -436,8 +439,8 @@ const f = (e) => {
|
|
|
436
439
|
let n = 0, s = e.replace(
|
|
437
440
|
/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,
|
|
438
441
|
(o, i, c, u) => {
|
|
439
|
-
const
|
|
440
|
-
return t[n] =
|
|
442
|
+
const p = c !== void 0 ? c : u || "";
|
|
443
|
+
return t[n] = p, `__HANDLEBARS_PLACEHOLDER_${n++}__`;
|
|
441
444
|
}
|
|
442
445
|
);
|
|
443
446
|
s = s.replace(/\//g, ".");
|
|
@@ -450,21 +453,21 @@ const f = (e) => {
|
|
|
450
453
|
} else o !== "" && r.push(o);
|
|
451
454
|
}
|
|
452
455
|
return r;
|
|
453
|
-
},
|
|
454
|
-
const n =
|
|
456
|
+
}, E = "dataSourceHandlebars", z = h.startup, K = function(e, t = {}) {
|
|
457
|
+
const n = H(e, new q()), s = W(e, {
|
|
455
458
|
contains: "{{",
|
|
456
|
-
importer: new
|
|
459
|
+
importer: new J()
|
|
457
460
|
});
|
|
458
461
|
M({
|
|
459
462
|
editor: e,
|
|
460
463
|
licenseKey: t.licenseKey,
|
|
461
464
|
plan: z,
|
|
462
|
-
pluginName:
|
|
465
|
+
pluginName: E,
|
|
463
466
|
cleanup: () => {
|
|
464
467
|
n(), s();
|
|
465
468
|
}
|
|
466
469
|
});
|
|
467
|
-
}, Q = G(K);
|
|
470
|
+
}, Q = G(K, E);
|
|
468
471
|
export {
|
|
469
472
|
Q as default
|
|
470
473
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";const k=require("handlebars/dist/cjs/handlebars.js"),x="app.grapesjs.com",$="app-stage.grapesjs.com",A="app2.grapesjs.com",L="app-stage2.grapesjs.com",b=[x,A,$,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],N="license:check:end",_=()=>typeof window<"u",R=({isDev:e,isStage:t,isPlatform:n})=>`${e?"":`https://${t?$:x}`}/${n?"platform-api":"api"}`,O=()=>{if(!_())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},w=()=>{const e=O();return!!e&&(b.includes(e)||b.some(t=>e.endsWith(t)))};async function D({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:a,body:r}){const i=`${t||R({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",p=u?`?${u}`:"",l=await fetch(`${i}${p}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),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.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))(d||{});const m={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function B(e,t){const n=e;return n.init=s=>{const a=r=>e(r,s);return a.__gjsPluginId=t,a},n}const G=(e,t)=>B(e,t);async function M({editor:e,plan:t,pluginName:n,licenseKey:s,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",n,"Reason:",l),r(e,n)},u=(l={})=>{var P;const{error:y,sdkLicense:I}=l,g=(P=l.plan)==null?void 0:P.category;if(!(I||l.license)||y)c(y||"Invalid license");else if(g){const T=m[t],S=m[g];T>S&&c({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(d.settings)&&(i=e.runCommand(d.settings),o=(i==null?void 0:i.baseUrl)||"");const p=l=>{a==null||a(l),l&&u(l)};if(!i){e.onReady(async()=>{if(!w())if(s){const l=await U({licenseKey:s,pluginName:n,baseApiUrl:o});p(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=j(i);p(l);return}e.on(N,l=>p(l))}const j=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function U(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await D({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const H=(e,t)=>(e.config.optsHtml={...e.config.optsHtml,exporter:t},()=>{e.config.optsHtml.exporter=void 0}),W=(e,t)=>{const n=a=>{const{input:r}=a,{contains:o}=t;(!o||r.includes(o))&&(a.input=t.importer.import(r))},s=e.Parser.events.htmlBefore;return e.on(s,n),()=>{e.off(s,n)}},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"},V={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},F={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},C={...v,...V,...F};class q{getHelperId(t){return C[t]||t}getFullPath({collectionId:t,path:n}){let s=n;return t&&(s=[this._sanitizeVariableName(t),n].filter(Boolean).join(".")),s||""}getVariableSyntax({dataResolver:t}){const{defaultValue:n}=t,s=this.getFullPath(t);return n?`{{#if ${s}}}{{{${s}}}}{{else}}${n}{{/if}}`:`{{{${s}}}}`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:n,dataSource:s}=t,a=s==null?void 0:s.path;let r="";if(t.startIndex!==void 0||t.endIndex!==void 0){const u=t.startIndex??0,p=t.endIndex!==void 0?t.endIndex:"";p!==""?r=` (slice ${a} ${u} ${p})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(n)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:t}){const n=t.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(t){if(!t)return"";const n=t,s=t;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(t,n,s){return v[t]?t==="isTruthy"?n:t==="isFalsy"?`!${n}`:`${t} ${n}`:`(${t} ${n} ${s})`}_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 J{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];const n=this.parse(t);return this.astToGrapesJS(n)}parse(t){try{return k.parse(t)}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(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 n="";if(t.body)for(const s of t.body)n+=this.astToGrapesJS(s);return n}handleContentStatement(t){return t.value||""}handleMustacheStatement(t,n={}){const s=this.getExpressionString(t.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(t,n){t.startsWith("@")?this.handleDirectCollectionReference(t,n):this.handleRelativePathReference(t,n)}handleDirectCollectionReference(t,n){if(this.isSpecialIterationVariable(t)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],t,n);return}const[s,...a]=t.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(s)?this.setCurrentItemResolver(s,r,n):this.handleParentReferenceFallback(t,n)}isSpecialIterationVariable(t){return["index","@index","key","@key"].includes(t)}setSpecialVariableResolver(t,n,s){s.collectionId=t;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};s.variableType=a[n]}setCurrentItemResolver(t,n,s){s.collectionId=t,s.variableType="currentItem",n&&(s.path=n)}handleRelativePathReference(t,n){const s=f(t),{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(t){const n=this.collectionStack.findLastIndex(r=>r===t[0]);if(n!==-1)return{parentLevel:this.collectionStack.length-1-n,remainingPathParts:t.slice(1)};let s=0;const a=[...t];for(;a[0]==="..";)s++,a.shift();return{parentLevel:s,remainingPathParts:a}}resolveRelativePath(t,n,s){const a=this.collectionStack[n];s.collectionId=a,s.variableType="currentItem",t!=="this"&&(s.path=t.startsWith("this.")?t.split(".").slice(1).join("."):t)}handleParentReferenceFallback(t,n){const s=f(t),{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(t){const n=t.path.original;switch(n){case"if":case"unless":return this.handleConditionalBlock(t,n);case"each":return this.handleEachBlock(t);default:return this.addMessage("warning",`Unsupported block helper: ${n}`,t.loc),this.handleGenericBlock(t)}}handleConditionalBlock(t,n){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(t.params[0])},operator:n==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(t.program),i=t.inverse?this.handleProgram(t.inverse):"";return`
|
|
2
|
+
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
|
|
3
|
+
<data-condition-true-content>${o}</data-condition-true-content>
|
|
4
|
+
<data-condition-false-content>${i}</data-condition-false-content>
|
|
5
|
+
</data-condition>
|
|
6
|
+
`}handleEachBlock(t){var r,o,i;const n=this.getExpressionString(t.params[0]);let s;t.params.length>=3&&t.params[1]==="as"&&((r=t.params[2])==null?void 0:r.type)==="PathExpression"?s=t.params[2].original:(i=(o=t.program)==null?void 0:o.blockParams)!=null&&i.length?s=t.program.blockParams[0]:s=`collection-${Math.random().toString(36).substring(2,10)}`,this.collectionStack.push(s);const a=this.handleProgram(t.program);return this.collectionStack.pop(),`
|
|
7
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:n},collectionId:s})}'>
|
|
8
|
+
<data-collection-item>${a}</data-collection-item>
|
|
9
|
+
</data-collection>
|
|
10
|
+
`}handleCommentStatement(t){return`<!--${t.value}-->`}handleElementNode(t){let n="";if(t.attributes)for(const a of t.attributes)a.value.type==="TextNode"?n+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,t.loc),n+=` ${a.name}="${this.getExpressionString(a.value)}"`);let s="";if(t.children)for(const a of t.children)s+=this.astToGrapesJS(a);return`<${t.tag}${n}>${s}</${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 n=this.handleProgram(t.program);return`<!-- Unsupported block: ${t.path.original} -->${n}`}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(s=>`${s.key}=${this.getExpressionString(s.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${t.type}`,t.loc),"")}addMessage(t,n,s){this.messages.push({type:t,message:n,location:s?{line:s.start.line,column:s.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 n=0,s=e.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const p=c!==void 0?c:u||"";return t[n]=p,`__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(t[c])}else o!==""&&r.push(o)}return r},E="dataSourceHandlebars",z=h.startup,K=function(e,t={}){const n=H(e,new q),s=W(e,{contains:"{{",importer:new J});M({editor:e,licenseKey:t.licenseKey,plan:z,pluginName:E,cleanup:()=>{n(),s()}})},Y=G(K,E);module.exports=Y;
|
|
@@ -1,4 +1,4 @@
|
|
|
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",T=()=>typeof window<"u",S=({isDev:t,isStage:e,isPlatform:n})=>`${t?"":`https://${e?P:g}`}/${n?"platform-api":"api"}`,k=()=>{if(!T())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:i}){const r=`${e||S({isDev:!1,isStage:!1})}${t}`,c={method:n,headers:{"Content-Type":"application/json",...s}};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.openEditCode="studio:openEditCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.settings="studio:settings",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(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:i}){let o="",r;const c=l=>{console.warn("Cleanup plugin:",n,"Reason:",l),i()},u=(l={})=>{var v;const{error:E,sdkLicense:W}=l,y=(v=l.plan)==null?void 0:v.category;if(!(W||l.license)||E)c(E||"Invalid license");else if(y){const V=x[e],F=x[y];V>F&&c({pluginRequiredPlan:e,licensePlan:y})}};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(!A())if(s){const l=await w({licenseKey:s,pluginName:n,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const l=L(r);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:i}=a,{contains:o}=e;(!o||i.includes(o))&&(a.input=e.importer.import(i))},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 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(n)}|`;return`{{#each ${i||a}${r}}}`}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: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(s)}}}`}_parseCondition(e){if(!e)return"";const n=e,s=e;if(s.statements&&s.logicalOperator==="and"||s.logicalOperator==="or"){const{statements:a}=s,i=s.logicalOperator,o=s.statements.map(r=>this._parseCondition(r)).join(" ");return a.length>1?`(${i} ${o})`:o}else{const a=n.operator,i=this.getHelperId(a),o=this._parseValue(n.left),r=this._parseValue(n.right);return this.getExpressionStr(i,o,r)}}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,i=n.message.match(/column (\d+)/),o=i?parseInt(i[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("/"),i=a.join(".");this.collectionStack.includes(s)?this.setCurrentItemResolver(s,i,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:i}=this.calculateParentLevel(s),o=i.join("."),r=this.collectionStack.length-1-a;r>=0&&r<this.collectionStack.length?this.resolveRelativePath(o,r,n):n.path=i.join(".")}calculateParentLevel(e){const n=this.collectionStack.findLastIndex(i=>i===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:i}=this.calculateParentLevel(s),o=i.join("."),r=this.collectionStack.length-1-a;r>=0&&r<this.collectionStack.length?this.resolveRelativePath(o,r,n):n.path=i.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 i={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:n==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(e.program),r=e.inverse?this.handleProgram(e.inverse):"";return`
|
|
1
|
+
(function(h,g){typeof exports=="object"&&typeof module<"u"?module.exports=g(require("handlebars/dist/cjs/handlebars.js")):typeof define=="function"&&define.amd?define(["handlebars/dist/cjs/handlebars.js"],g):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_dataSourceHandlebars=g(h.Handlebars))})(this,function(h){"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",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],T="license:check:end",S=()=>typeof window<"u",k=({isDev:t,isStage:e,isPlatform:n})=>`${t?"":`https://${e?y:g}`}/${n?"platform-api":"api"}`,A=()=>{if(!S())return"";const{hostname:t}=window.location;if(t)return t;try{return window.parent.location.hostname||""}catch{return""}},N=()=>{const t=A();return!!t&&(m.includes(t)||m.some(e=>t.endsWith(e)))};async function O({path:t,baseApiUrl:e,method:n="GET",headers:s={},params:a,body:i}){const r=`${e||k({isDev:!1,isStage:!1})}${t}`,c={method:n,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const u=a?new URLSearchParams(a).toString():"",p=u?`?${u}`:"",l=await fetch(`${r}${p}`,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.openEditCode="studio:openEditCode",t.openBlocks="studio:openBlocks",t.appendComponent="studio:appendComponent",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 _(t,e){const n=t;return n.init=s=>{const a=i=>t(i,s);return a.__gjsPluginId=e,a},n}const R=(t,e)=>_(t,e);async function L({editor:t,plan:e,pluginName:n,licenseKey:s,onLicenseCheckResponse:a,cleanup:i}){let o="",r;const c=l=>{console.warn("Cleanup plugin:",n,"Reason:",l),i(t,n)},u=(l={})=>{var I;const{error:v,sdkLicense:W}=l,P=(I=l.plan)==null?void 0:I.category;if(!(W||l.license)||v)c(v||"Invalid license");else if(P){const V=x[e],F=x[P];V>F&&c({pluginRequiredPlan:e,licensePlan:P})}};t.Commands.has(f.settings)&&(r=t.runCommand(f.settings),o=(r==null?void 0:r.baseUrl)||"");const p=l=>{a==null||a(l),l&&u(l)};if(!r){t.onReady(async()=>{if(!N())if(s){const l=await D({licenseKey:s,pluginName:n,baseApiUrl:o});p(l)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const l=w(r);p(l);return}t.on(T,l=>p(l))}const w=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function D(t){const{licenseKey:e,pluginName:n,baseApiUrl:s}=t;try{return(await O({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 G=(t,e)=>(t.config.optsHtml={...t.config.optsHtml,exporter:e},()=>{t.config.optsHtml.exporter=void 0}),M=(t,e)=>{const n=a=>{const{input:i}=a,{contains:o}=e;(!o||i.includes(o))&&(a.input=e.importer.import(i))},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"},B={...$,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class j{getHelperId(e){return B[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 i="";if(e.startIndex!==void 0||e.endIndex!==void 0){const u=e.startIndex??0,p=e.endIndex!==void 0?e.endIndex:"";p!==""?i=` (slice ${a} ${u} ${p})`:i=` (slice ${a} ${u})`}const r=` as |${this._sanitizeVariableName(n)}|`;return`{{#each ${i||a}${r}}}`}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: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(s)}}}`}_parseCondition(e){if(!e)return"";const n=e,s=e;if(s.statements&&s.logicalOperator==="and"||s.logicalOperator==="or"){const{statements:a}=s,i=s.logicalOperator,o=s.statements.map(r=>this._parseCondition(r)).join(" ");return a.length>1?`(${i} ${o})`:o}else{const a=n.operator,i=this.getHelperId(a),o=this._parseValue(n.left),r=this._parseValue(n.right);return this.getExpressionStr(i,o,r)}}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 U{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const n=this.parse(e);return this.astToGrapesJS(n)}parse(e){try{return h.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,i=n.message.match(/column (\d+)/),o=i?parseInt(i[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("/"),i=a.join(".");this.collectionStack.includes(s)?this.setCurrentItemResolver(s,i,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:i}=this.calculateParentLevel(s),o=i.join("."),r=this.collectionStack.length-1-a;r>=0&&r<this.collectionStack.length?this.resolveRelativePath(o,r,n):n.path=i.join(".")}calculateParentLevel(e){const n=this.collectionStack.findLastIndex(i=>i===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:i}=this.calculateParentLevel(s),o=i.join("."),r=this.collectionStack.length-1-a;r>=0&&r<this.collectionStack.length?this.resolveRelativePath(o,r,n):n.path=i.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 i={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:n==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(e.program),r=e.inverse?this.handleProgram(e.inverse):"";return`
|
|
2
2
|
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:i})}'>
|
|
3
3
|
<data-condition-true-content>${o}</data-condition-true-content>
|
|
4
4
|
<data-condition-false-content>${r}</data-condition-false-content>
|
|
@@ -7,4 +7,4 @@
|
|
|
7
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 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,r,c,u)=>{const
|
|
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,r,c,u)=>{const p=c!==void 0?c:u||"";return e[n]=p,`__HANDLEBARS_PLACEHOLDER_${n++}__`});s=s.replace(/\//g,".");const a=s.split("."),i=[];for(const o of a){const r=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);if(r){const c=parseInt(r[1],10);i.push(e[c])}else o!==""&&i.push(o)}return i},E="dataSourceHandlebars",H=d.startup;return R(function(t,e={}){const n=G(t,new j),s=M(t,{contains:"{{",importer:new U});L({editor:t,licenseKey:e.licenseKey,plan:H,pluginName:E,cleanup:()=>{n(),s()}})},E)});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const k="app.grapesjs.com",A="app-stage.grapesjs.com",R="app2.grapesjs.com",$="app-stage2.grapesjs.com",x=[k,R,A,$,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],G="license:check:end",B=()=>typeof window<"u",N=({isDev:e,isStage:n,isPlatform:r})=>`${e?"":`https://${n?A:k}`}/${r?"platform-api":"api"}`,I=()=>{if(!B())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},M=()=>{const e=I();return!!e&&(x.includes(e)||x.some(n=>e.endsWith(n)))};async function U({path:e,baseApiUrl:n,method:r="GET",headers:s={},params:c,body:a}){const i=`${n||N({isDev:!1,isStage:!1})}${e}`,g={method:r,headers:{"Content-Type":"application/json",...s}};a&&(g.body=JSON.stringify(a));const p=c?new URLSearchParams(c).toString():"",d=p?`?${p}`:"",o=await fetch(`${i}${d}`,g);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{}),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.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))(T||{});const O={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function m(e,n){const r=e;return r.init=s=>{const c=a=>e(a,s);return c.__gjsPluginId=n,c},r}const q=(e,n)=>m(e,n);async function X({editor:e,plan:n,pluginName:r,licenseKey:s,onLicenseCheckResponse:c,cleanup:a}){let u="",i;const g=o=>{console.warn("Cleanup plugin:",r,"Reason:",o),a(e,r)},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[n],w=O[l];P>w&&g({pluginRequiredPlan:n,licensePlan:l})}};e.Commands.has(T.settings)&&(i=e.runCommand(T.settings),u=(i==null?void 0:i.baseUrl)||"");const d=o=>{c==null||c(o),o&&p(o)};if(!i){e.onReady(async()=>{if(!M())if(s){const o=await z({licenseKey:s,pluginName:r,baseApiUrl:u});d(o)}else g("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const o=F(i);d(o);return}e.on(G,o=>d(o))}const F=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function z(e){const{licenseKey:n,pluginName:r,baseApiUrl:s}=e;try{return(await U({baseApiUrl:s,path:`/sdk/${n||"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(n=>`[data-gjs-type="${n}"]`).join(","),D="dialogComponent",H=function(e,n={}){const{Blocks:r,Components:s}=e,{licenseKey:c}=n,a="gjs-plg-dialog",u="gjs-plg-dialog-overlay",i="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(a,{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:
|
|
6
|
-
.${
|
|
5
|
+
`,category:"Extra",content:{type:a},activate:!0,...n.block}),s.addType(a,{model:{defaults:{tagName:"div",attributes:{class:a,"data-type-role":a},components:[{type:u},{type:v}],draggable:j("wrapper"),droppable:j(a),styles:`
|
|
6
|
+
.${a} {
|
|
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 W(){f.style.display="none"}y?(t._onCloseWhenPressingX=W,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(W){W.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
|
|
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 W(){f.style.display="none"}y?(t._onCloseWhenPressingX=W,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(W){W.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 _(y){const f=t.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function h(){const W=document.documentElement.scrollTop;y&&W>=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),_(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"}}}),s.addType(u,{model:{defaults:{tagName:"div",attributes:{class:u,"data-type-role":u},components:{type:i},droppable:!1,draggable:!1,styles:`
|
|
11
11
|
.${u} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
justify-content: center;
|
|
20
20
|
background-color: rgba(0, 0, 0, 0.5);
|
|
21
21
|
}
|
|
22
|
-
`}}}),
|
|
23
|
-
.${
|
|
22
|
+
`}}}),s.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:g},{type:p},{type:d}],droppable:!1,draggable:!1,styles:`
|
|
23
|
+
.${i} {
|
|
24
24
|
position: relative;
|
|
25
25
|
background-color: #fff;
|
|
26
26
|
border-radius: 10px;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
height: 600px;
|
|
31
31
|
box-sizing: border-box;
|
|
32
32
|
}
|
|
33
|
-
`}}}),
|
|
33
|
+
`}}}),s.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
|
+
`}}}),s.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
|
+
`}}}),s.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
|
+
`}}}),s.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
|
+
`}}}),s.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=""})}}}),X({editor:e,licenseKey:c,plan:E.startup,pluginName:D,cleanup:()=>{r.remove(a),s.removeType(a)}})},K=q(H,D);module.exports=K;
|