@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33

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