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