@grapesjs/studio-sdk-plugins 1.0.25 → 1.0.26-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dataSourceEjs/EjsExporter.d.ts +2 -2
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
- package/dist/flexComponent/index.cjs.js +1 -1
- package/dist/flexComponent/index.es.js +1 -1
- package/dist/flexComponent/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +4 -4
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +1 -1
- package/dist/iconifyComponent/index.es.js +1 -1
- package/dist/iconifyComponent/index.umd.js +1 -1
- package/dist/index.cjs.js +21 -21
- package/dist/index.es.js +219 -216
- package/dist/index.umd.js +2 -2
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +19 -19
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/types.d.ts +2 -1
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +101 -101
- package/dist/presetPrintable/index.umd.js +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rendererReact/index.cjs.d.ts +3 -2
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.d.ts +3 -2
- package/dist/rendererReact/index.es.d.ts +3 -2
- package/dist/rendererReact/index.es.js +219 -153
- package/dist/rendererReact/index.js +1 -0
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rendererReact/rendererCanvas/RenderCanvasComponent.d.ts +4 -2
- package/dist/rendererReact/rendererCanvas/customRenderer.d.ts +2 -2
- package/dist/rendererReact/rendererCanvas/util.d.ts +27 -7
- package/dist/rendererReact/rendererProject/RenderComponent.d.ts +2 -0
- package/dist/rendererReact/rendererProject/RenderError.d.ts +2 -0
- package/dist/rendererReact/rendererProject/RenderPage.d.ts +2 -0
- package/dist/rendererReact/rendererProject/RenderProject.d.ts +3 -0
- package/dist/rendererReact/rendererProject/index.cjs.d.ts +1 -2
- package/dist/rendererReact/rendererProject/index.cjs.js +2 -10
- package/dist/rendererReact/rendererProject/index.d.ts +1 -2
- package/dist/rendererReact/rendererProject/index.es.d.ts +1 -2
- package/dist/rendererReact/rendererProject/index.es.js +206 -227
- package/dist/rendererReact/rendererProject/index.js +2 -10
- package/dist/rendererReact/rendererProject/index.umd.js +2 -10
- package/dist/rendererReact/rendererProject/parser/parser.d.ts +34 -53
- package/dist/rendererReact/rendererProject/types.d.ts +18 -4
- package/dist/rendererReact/rendererProject/util.d.ts +0 -11
- package/dist/rendererReact/shared/shared.d.ts +3 -0
- package/dist/rendererReact/shared/types.d.ts +150 -44
- package/dist/rendererReact/shared/util.d.ts +7 -1
- package/dist/rendererReact/types.d.ts +9 -12
- package/dist/rendererReact/typesSchema.d.ts +116 -49
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +1 -1
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +15 -12
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +6 -6
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +14 -2
- package/dist/rendererReact/rendererProject/GrapesJSProject.d.ts +0 -3
- package/dist/rendererReact/rendererProject/RenderProjectComponent.d.ts +0 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RendererReactOptions } from './types';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
declare const _default: import('../utils').PluginWithInit<RendererReactOptions>;
|
|
3
4
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const y=require("react/jsx-runtime"),g=require("react"),I=require("react-dom/client"),j="app.grapesjs.com",U="app-stage.grapesjs.com",N=[j,U,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],W="license:check:start",B="license:check:end",$=()=>typeof window<"u",F=({isDev:e,isStage:t})=>`${e?"":`https://${t?U:j}`}/api`,K=()=>{const e=$()&&window.location.hostname;return!!e&&(N.includes(e)||N.some(t=>e.endsWith(t)))},V=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,n)=>(n?"-":"")+t.toLowerCase()),T=e=>typeof e=="string";function z(e){return typeof e=="function"}async function M({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:r,body:o}){const c=`${t||F({isDev:!1,isStage:!1})}${e}`,a={method:n,headers:{"Content-Type":"application/json",...s}};o&&(a.body=JSON.stringify(o));const u=r?new URLSearchParams(r).toString():"",l=u?`?${u}`:"",d=await fetch(`${c}${l}`,a);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}var C=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(C||{});const P={[C.free]:0,[C.startup]:10,[C.business]:20,[C.enterprise]:30};function q(e){const t=e;return t.init=n=>s=>e(s,n),t}const J=e=>q(e);async function G({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:r}){let o="",i=!1;const c=K(),a=l=>{console.warn("Cleanup plugin:",n,"Reason:",l),r()},u=(l={})=>{var h;const{error:d,sdkLicense:m}=l,f=(h=l.plan)==null?void 0:h.category;if(!(m||l.license)||d)a(d||"Invalid license");else if(f){const k=P[t],w=P[f];k>w&&a({pluginRequiredPlan:t,licensePlan:f})}};e.on(W,l=>{o=l==null?void 0:l.baseApiUrl,i=!0}),e.on(B,l=>{u(l)}),setTimeout(async()=>{if(!i){if(c)return;if(s){const l=await H({licenseKey:s,pluginName:n,baseApiUrl:o});l&&u(l)}else a("The `licenseKey` option not provided")}},2e3)}async function H(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await M({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 Z(e){const t={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=V(n);t[s]=e[n]}return t}const Q=(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 X(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 Y(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return O(e);if(typeof e=="string"){let t=X(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 ee(e){return L[e]?L[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase()):e}function te(e){var n;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 o=ee(s);((n=e.xmlns)==null?void 0:n.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||oe.has(o)||o.startsWith("svg")?t[o]=r:!ne.has(o)&&!o.startsWith("on")&&!o.startsWith("aria-")&&!o.startsWith("data-")?t[s]=r:t[o]=r}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"]),oe=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"]),L={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},E=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function se(e){return t=>{const n=t.getContent();E(n)&&t.set({content:b({...e,model:n}),reactContent:n})}}const re=e=>t=>{const n=t.component;E(n)&&(t.component={components:b({...e,model:n})})};function b(e){const{model:t,editor:n,config:s}=e;if(E(t)){const r=t,o={},{type:i,props:c={}}=r,{children:a,className:u,style:l,...d}=c,m=p=>({type:"textnode",content:p}),f=typeof i=="symbol";if(z(i)){const p=Q(s,i);o.type=p==null?void 0:p.type}else n.Components.getType(i)?o.type=i:f||(o.tagName=i);if(u&&(o.classes=u),l&&(o.style=Z(l)),Array.isArray(a)?o.components=a.map(p=>T(p)?m(p):b({...e,model:p})).filter(Boolean):T(a)&&(o.components=m(a)),Object.keys(d).length){const p=n.Parser.parserHtml.splitPropsFromAttr(d);o.attributes=p.attrs,Object.assign(o,p.props)}return o}}function ce(e){const{component:t}=e,[n,s]=g.useState(0),[r,o]=g.useState();return g.useEffect(()=>{if(!t)return()=>{};const c=()=>s(p=>p+1),a=()=>{[...t.views].forEach(h=>h.remove()),o(void 0)},{em:u}=t,l=u.Components.events,m=[...["components","attributes","classes"].map(p=>`${l.update}:${p}`),"rerender"].join(" "),f=[l.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=ie({...e,el:c});o(a)}}}function ie(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:u}=i,l=n.attributes.type||"default",d=((a=i.getType(l))==null?void 0:a.view)||u,m={...i.config,frameView:r,em:o},f=d.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:m,model:n})}return c.el=s,c.render(),c}function ae(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,u=!c&&!i,l=()=>({disabled:u}),d=()=>({disableClasses:!i,disableComponent:!c});n.addType(r,{isComponent:p=>(p==null?void 0:p.tagName)===r,model:{defaults:{type:r,traits:((m=o.props)==null?void 0:m.call(o))||[],droppable:!!a,stylable:!u,styleManager:l,selectorManager:d,...((f=o.model)==null?void 0:f.defaults)||{}}}})})}function _(e){var x;const{component:t,config:n,editor:s,frameView:r,onMount:o,tagName:i,children:c}=e,{key:a,view:u,connectDom:l}=ce(e);g.useEffect(()=>{if(!u&&!o)return;const v=setTimeout(()=>{u&&(o==null||o(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const d=t.get("type")||"default",m=t.content,f=(x=n.components)==null?void 0:x[d],p=(f==null?void 0:f.component)||i||t.tagName||"div",h=t.components(),k=h.length?h.map(v=>y.jsx(_,{component:v,config:n,editor:s,frameView:r},v.cid)):[m||void 0],w=te(t.getAttributes()),A=f==null?void 0:f.editorRender,S=[...k,c].filter(v=>v??!1),R=S.length?S:null;if(A)return y.jsx(A,{props:w,editor:s,component:t,connectDom:l,children:R});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:l,style:f.wrapperStyle,children:y.jsx(p,{...w,children:R})});if(t.isInstanceOf("textnode"))return m;const D=t.isInstanceOf("text")?a:void 0;return g.createElement(p,{...w,ref:l,key:D},t.get("void")?null:R)}const le=e=>{const{frame:t,window:n,onMount:s,editor:r}=e,o=r.Canvas.events,{root:i}=t;try{const c=I.createRoot(n.document.body);c.render(y.jsx(pe,{...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 pe(e){const{editor:t,component:n,window:s,frameView:r,config:o,onMount:i}=e,c=s.document,a=o.rootComponent||g.Fragment,u=o.rootComponent?{editorProps:{doc:c,editor:t,frameView:r}}:{},l=(o==null?void 0:o.bodyAfter)||g.Fragment;return y.jsx(a,{...u,children:y.jsx(_,{tagName:"div",component:n,config:o,editor:t,frameView:r,onMount:i,children:y.jsx(l,{...u})})})}const ue="rendererReact",fe=C.startup,de=function(e,t={}){const{Blocks:n,Pages:s}=e,r=n.events,o=s.events;e.Canvas.config.customRenderer=c=>le({...c,config:t}),e.Components.config.processor=c=>b({model:c,editor:e,config:t}),ae(e,t);const i=[[r.add,se({editor:e,config:t})],[o.addBefore,re({editor:e,config:t})]];i.forEach(([c,a])=>e.on(c,a)),G({editor:e,licenseKey:t.licenseKey,plan:fe,pluginName:ue,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([c,a])=>e.off(c,a))}})},me=J(de);module.exports=me;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RendererReactOptions } from './types';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
declare const _default: import('../utils').PluginWithInit<RendererReactOptions>;
|
|
3
4
|
export default _default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RendererReactOptions } from './types';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
declare const _default: import('../utils').PluginWithInit<RendererReactOptions>;
|
|
3
4
|
export default _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createRoot as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useEffect as _, createElement as $, Fragment as T } from "react";
|
|
3
|
+
import { createRoot as j } from "react-dom/client";
|
|
4
|
+
const D = "app.grapesjs.com", I = "app-stage.grapesjs.com", x = [
|
|
5
|
+
D,
|
|
6
|
+
I,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
@@ -12,82 +12,85 @@ const N = "app.grapesjs.com", T = "app-stage.grapesjs.com", b = [
|
|
|
12
12
|
// For stackblitz.com demos
|
|
13
13
|
"-sandpack.codesandbox.io"
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
],
|
|
16
|
-
const e =
|
|
17
|
-
return !!e && (
|
|
18
|
-
};
|
|
19
|
-
|
|
15
|
+
], K = "license:check:start", F = "license:check:end", V = () => typeof window < "u", z = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? I : D}`}/api`, M = () => {
|
|
16
|
+
const e = V() && window.location.hostname;
|
|
17
|
+
return !!e && (x.includes(e) || x.some((t) => e.endsWith(t)));
|
|
18
|
+
}, J = (e) => e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, n) => (n ? "-" : "") + t.toLowerCase()), P = (e) => typeof e == "string";
|
|
19
|
+
function q(e) {
|
|
20
|
+
return typeof e == "function";
|
|
21
|
+
}
|
|
22
|
+
async function G({
|
|
20
23
|
path: e,
|
|
21
24
|
baseApiUrl: t,
|
|
22
25
|
method: n = "GET",
|
|
23
26
|
headers: s = {},
|
|
24
27
|
params: r,
|
|
25
|
-
body:
|
|
28
|
+
body: o
|
|
26
29
|
}) {
|
|
27
|
-
const c = `${t ||
|
|
30
|
+
const c = `${t || z({ isDev: !1, isStage: !1 })}${e}`, a = {
|
|
28
31
|
method: n,
|
|
29
32
|
headers: {
|
|
30
33
|
"Content-Type": "application/json",
|
|
31
34
|
...s
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
37
|
+
o && (a.body = JSON.stringify(o));
|
|
38
|
+
const f = r ? new URLSearchParams(r).toString() : "", l = f ? `?${f}` : "", d = await fetch(`${c}${l}`, a);
|
|
36
39
|
if (!d.ok)
|
|
37
40
|
throw new Error(`HTTP error! status: ${d.status}`);
|
|
38
41
|
return d.json();
|
|
39
42
|
}
|
|
40
|
-
var
|
|
41
|
-
const
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
43
|
+
var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {});
|
|
44
|
+
const O = {
|
|
45
|
+
[v.free]: 0,
|
|
46
|
+
[v.startup]: 10,
|
|
47
|
+
[v.business]: 20,
|
|
48
|
+
[v.enterprise]: 30
|
|
46
49
|
};
|
|
47
|
-
function
|
|
50
|
+
function H(e) {
|
|
48
51
|
const t = e;
|
|
49
52
|
return t.init = (n) => (s) => e(s, n), t;
|
|
50
53
|
}
|
|
51
|
-
const
|
|
52
|
-
async function
|
|
54
|
+
const Z = (e) => /* @__PURE__ */ H(e);
|
|
55
|
+
async function Q({
|
|
53
56
|
editor: e,
|
|
54
57
|
plan: t,
|
|
55
58
|
pluginName: n,
|
|
56
59
|
licenseKey: s,
|
|
57
60
|
cleanup: r
|
|
58
61
|
}) {
|
|
59
|
-
let
|
|
60
|
-
const c =
|
|
61
|
-
console.warn("Cleanup plugin:", n, "Reason:",
|
|
62
|
-
},
|
|
62
|
+
let o = "", i = !1;
|
|
63
|
+
const c = M(), a = (l) => {
|
|
64
|
+
console.warn("Cleanup plugin:", n, "Reason:", l), r();
|
|
65
|
+
}, f = (l = {}) => {
|
|
63
66
|
var h;
|
|
64
|
-
const { error: d, sdkLicense:
|
|
65
|
-
if (!(
|
|
66
|
-
|
|
67
|
-
else if (
|
|
68
|
-
const
|
|
69
|
-
|
|
67
|
+
const { error: d, sdkLicense: m } = l, u = (h = l.plan) == null ? void 0 : h.category;
|
|
68
|
+
if (!(m || l.license) || d)
|
|
69
|
+
a(d || "Invalid license");
|
|
70
|
+
else if (u) {
|
|
71
|
+
const b = O[t], C = O[u];
|
|
72
|
+
b > C && a({ pluginRequiredPlan: t, licensePlan: u });
|
|
70
73
|
}
|
|
71
74
|
};
|
|
72
|
-
e.on(
|
|
73
|
-
|
|
74
|
-
}), e.on(
|
|
75
|
-
|
|
75
|
+
e.on(K, (l) => {
|
|
76
|
+
o = l == null ? void 0 : l.baseApiUrl, i = !0;
|
|
77
|
+
}), e.on(F, (l) => {
|
|
78
|
+
f(l);
|
|
76
79
|
}), setTimeout(async () => {
|
|
77
|
-
if (!
|
|
80
|
+
if (!i) {
|
|
78
81
|
if (c) return;
|
|
79
82
|
if (s) {
|
|
80
|
-
const
|
|
81
|
-
|
|
83
|
+
const l = await X({ licenseKey: s, pluginName: n, baseApiUrl: o });
|
|
84
|
+
l && f(l);
|
|
82
85
|
} else
|
|
83
|
-
|
|
86
|
+
a("The `licenseKey` option not provided");
|
|
84
87
|
}
|
|
85
88
|
}, 2e3);
|
|
86
89
|
}
|
|
87
|
-
async function
|
|
90
|
+
async function X(e) {
|
|
88
91
|
const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
|
|
89
92
|
try {
|
|
90
|
-
return (await
|
|
93
|
+
return (await G({
|
|
91
94
|
baseApiUrl: s,
|
|
92
95
|
path: `/sdk/${t || "na"}`,
|
|
93
96
|
method: "POST",
|
|
@@ -100,43 +103,60 @@ async function B(e) {
|
|
|
100
103
|
return console.error("Error during SDK license check:", r), !1;
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
|
-
function
|
|
106
|
+
function Y(e) {
|
|
107
|
+
const t = {};
|
|
108
|
+
for (const n in e)
|
|
109
|
+
if (Object.prototype.hasOwnProperty.call(e, n)) {
|
|
110
|
+
const s = J(n);
|
|
111
|
+
t[s] = e[n];
|
|
112
|
+
}
|
|
113
|
+
return t;
|
|
114
|
+
}
|
|
115
|
+
const ee = (e, t) => {
|
|
116
|
+
const n = e.components || {};
|
|
117
|
+
for (const s in n) {
|
|
118
|
+
const r = n[s];
|
|
119
|
+
if (r.component === t)
|
|
120
|
+
return { cmpConfig: r, type: s };
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
function L(e) {
|
|
104
124
|
const t = {};
|
|
105
125
|
let n = !1;
|
|
106
126
|
for (const s in e)
|
|
107
127
|
if (Object.prototype.hasOwnProperty.call(e, s)) {
|
|
108
128
|
const r = e[s];
|
|
109
129
|
if (typeof r == "string" || typeof r == "number") {
|
|
110
|
-
const
|
|
111
|
-
t[
|
|
130
|
+
const o = s.includes("-") ? s.replace(/-([a-z])/g, (i) => i[1].toUpperCase()) : s;
|
|
131
|
+
t[o] = r, n = !0;
|
|
112
132
|
}
|
|
113
133
|
}
|
|
114
134
|
return n ? t : void 0;
|
|
115
135
|
}
|
|
116
|
-
function
|
|
136
|
+
function te(e) {
|
|
117
137
|
const t = {};
|
|
118
138
|
return e.split(";").forEach((n) => {
|
|
119
139
|
if (!n.trim()) return;
|
|
120
140
|
const s = n.indexOf(":");
|
|
121
141
|
if (s > 0) {
|
|
122
|
-
const r = n.substring(0, s).trim(),
|
|
123
|
-
if (r &&
|
|
124
|
-
const
|
|
125
|
-
t[
|
|
142
|
+
const r = n.substring(0, s).trim(), o = n.substring(s + 1).trim();
|
|
143
|
+
if (r && o) {
|
|
144
|
+
const i = r.replace(/-([a-z])/g, (c) => c[1].toUpperCase());
|
|
145
|
+
t[i] = o;
|
|
126
146
|
}
|
|
127
147
|
}
|
|
128
148
|
}), Object.keys(t).length > 0 ? t : void 0;
|
|
129
149
|
}
|
|
130
|
-
function
|
|
150
|
+
function ne(e) {
|
|
131
151
|
if (e) {
|
|
132
152
|
if (typeof e == "object" && !Array.isArray(e))
|
|
133
|
-
return
|
|
153
|
+
return L(e);
|
|
134
154
|
if (typeof e == "string") {
|
|
135
|
-
let t =
|
|
155
|
+
let t = te(e);
|
|
136
156
|
if (!t)
|
|
137
157
|
try {
|
|
138
158
|
const n = JSON.parse(e);
|
|
139
|
-
typeof n == "object" && n !== null && !Array.isArray(n) && (t =
|
|
159
|
+
typeof n == "object" && n !== null && !Array.isArray(n) && (t = L(n));
|
|
140
160
|
} catch (n) {
|
|
141
161
|
console.error("Failed to parse style string as JSON", n);
|
|
142
162
|
}
|
|
@@ -148,32 +168,32 @@ function q(e) {
|
|
|
148
168
|
if (typeof n == "object" && n !== null) {
|
|
149
169
|
const s = n.name || n.property, r = n.value;
|
|
150
170
|
if (typeof s == "string" && s && r !== void 0 && r !== "") {
|
|
151
|
-
const
|
|
152
|
-
t[
|
|
171
|
+
const o = s.replace(/-([a-z])/g, (i) => i[1].toUpperCase());
|
|
172
|
+
t[o] = r;
|
|
153
173
|
}
|
|
154
174
|
}
|
|
155
175
|
}), Object.keys(t).length > 0 ? t : void 0;
|
|
156
176
|
}
|
|
157
177
|
}
|
|
158
178
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
179
|
+
function oe(e) {
|
|
180
|
+
return U[e] ? U[e] : e.includes("-") ? e.replace(/-([a-z])/g, (t, n) => n.toUpperCase()) : e;
|
|
161
181
|
}
|
|
162
|
-
function
|
|
163
|
-
var
|
|
164
|
-
const t = {}
|
|
165
|
-
for (const [
|
|
166
|
-
if (
|
|
167
|
-
t.style =
|
|
168
|
-
else if (
|
|
169
|
-
t[
|
|
182
|
+
function se(e) {
|
|
183
|
+
var n;
|
|
184
|
+
const t = {};
|
|
185
|
+
for (const [s, r] of Object.entries(e))
|
|
186
|
+
if (s === "style")
|
|
187
|
+
t.style = ne(r);
|
|
188
|
+
else if (s.startsWith("data-"))
|
|
189
|
+
t[s] = r;
|
|
170
190
|
else {
|
|
171
|
-
const o =
|
|
172
|
-
n ||
|
|
191
|
+
const o = oe(s);
|
|
192
|
+
((n = e.xmlns) == null ? void 0 : n.includes("svg")) || e.viewBox !== void 0 || e.d !== void 0 || ce.has(o) || o.startsWith("svg") ? t[o] = r : !re.has(o) && !o.startsWith("on") && !o.startsWith("aria-") && !o.startsWith("data-") ? t[s] = r : t[o] = r;
|
|
173
193
|
}
|
|
174
194
|
return t;
|
|
175
195
|
}
|
|
176
|
-
const
|
|
196
|
+
const re = /* @__PURE__ */ new Set([
|
|
177
197
|
"className",
|
|
178
198
|
"id",
|
|
179
199
|
"style",
|
|
@@ -214,7 +234,7 @@ const Q = /* @__PURE__ */ new Set([
|
|
|
214
234
|
"aria-labelledby",
|
|
215
235
|
"aria-describedby",
|
|
216
236
|
"role"
|
|
217
|
-
]),
|
|
237
|
+
]), ce = /* @__PURE__ */ new Set([
|
|
218
238
|
"x",
|
|
219
239
|
"y",
|
|
220
240
|
"d",
|
|
@@ -257,7 +277,7 @@ const Q = /* @__PURE__ */ new Set([
|
|
|
257
277
|
"clipPath",
|
|
258
278
|
"overflow",
|
|
259
279
|
"pointerEvents"
|
|
260
|
-
]),
|
|
280
|
+
]), U = {
|
|
261
281
|
class: "className",
|
|
262
282
|
for: "htmlFor",
|
|
263
283
|
"http-equiv": "httpEquiv",
|
|
@@ -274,132 +294,178 @@ const Q = /* @__PURE__ */ new Set([
|
|
|
274
294
|
"font-family": "fontFamily",
|
|
275
295
|
"font-size": "fontSize",
|
|
276
296
|
"text-anchor": "textAnchor"
|
|
277
|
-
};
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
r(c);
|
|
286
|
-
},
|
|
287
|
-
[s]
|
|
288
|
-
),
|
|
289
|
-
view: s
|
|
297
|
+
}, R = (e) => (e == null ? void 0 : e.$$typeof) && typeof e.props == "object";
|
|
298
|
+
function ie(e) {
|
|
299
|
+
return (t) => {
|
|
300
|
+
const n = t.getContent();
|
|
301
|
+
R(n) && t.set({
|
|
302
|
+
content: w({ ...e, model: n }),
|
|
303
|
+
reactContent: n
|
|
304
|
+
});
|
|
290
305
|
};
|
|
291
306
|
}
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
307
|
+
const ae = (e) => (t) => {
|
|
308
|
+
const n = t.component;
|
|
309
|
+
R(n) && (t.component = { components: w({ ...e, model: n }) });
|
|
310
|
+
};
|
|
311
|
+
function w(e) {
|
|
312
|
+
const { model: t, editor: n, config: s } = e;
|
|
313
|
+
if (R(t)) {
|
|
314
|
+
const r = t, o = {}, { type: i, props: c = {} } = r, { children: a, className: f, style: l, ...d } = c, m = (p) => ({ type: "textnode", content: p }), u = typeof i == "symbol";
|
|
315
|
+
if (q(i)) {
|
|
316
|
+
const p = ee(s, i);
|
|
317
|
+
o.type = p == null ? void 0 : p.type;
|
|
318
|
+
} else n.Components.getType(i) ? o.type = i : u || (o.tagName = i);
|
|
319
|
+
if (f && (o.classes = f), l && (o.style = Y(l)), Array.isArray(a) ? o.components = a.map((p) => P(p) ? m(p) : w({ ...e, model: p })).filter(Boolean) : P(a) && (o.components = m(a)), Object.keys(d).length) {
|
|
320
|
+
const p = n.Parser.parserHtml.splitPropsFromAttr(d);
|
|
321
|
+
o.attributes = p.attrs, Object.assign(o, p.props);
|
|
322
|
+
}
|
|
323
|
+
return o;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function le(e) {
|
|
327
|
+
const { component: t } = e, [n, s] = N(0), [r, o] = N();
|
|
328
|
+
return _(() => {
|
|
329
|
+
if (!t) return () => {
|
|
296
330
|
};
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
331
|
+
const c = () => s((p) => p + 1), a = () => {
|
|
332
|
+
[...t.views].forEach((h) => h.remove()), o(void 0);
|
|
333
|
+
}, { em: f } = t, l = f.Components.events, m = [...["components", "attributes", "classes"].map((p) => `${l.update}:${p}`), "rerender"].join(" "), u = [l.removed, "rerender"].join(" ");
|
|
334
|
+
return t.on(m, c), t.on(u, a), () => {
|
|
335
|
+
t.off(m, c), t.off(u, a), a();
|
|
336
|
+
};
|
|
337
|
+
}, [t]), { key: n, view: r, connectDom: (c) => {
|
|
338
|
+
if (!c) return;
|
|
339
|
+
const a = pe({ ...e, el: c });
|
|
340
|
+
o(a);
|
|
341
|
+
} };
|
|
300
342
|
}
|
|
301
|
-
function
|
|
302
|
-
var
|
|
303
|
-
const {
|
|
304
|
-
let
|
|
305
|
-
if ((
|
|
306
|
-
return
|
|
307
|
-
if (!
|
|
308
|
-
const { ComponentView:
|
|
343
|
+
function pe(e) {
|
|
344
|
+
var a;
|
|
345
|
+
const { editor: t, component: n, el: s, frameView: r } = e, { em: o, Components: i } = t;
|
|
346
|
+
let c = n.getView(r.model);
|
|
347
|
+
if ((c == null ? void 0 : c.el) === s)
|
|
348
|
+
return c;
|
|
349
|
+
if (!c) {
|
|
350
|
+
const { ComponentView: f } = i, l = n.attributes.type || "default", d = ((a = i.getType(l)) == null ? void 0 : a.view) || f, m = { ...i.config, frameView: r, em: o }, u = d.extend({
|
|
309
351
|
initComponents() {
|
|
310
352
|
},
|
|
311
353
|
_createElement() {
|
|
312
|
-
return
|
|
354
|
+
return s;
|
|
355
|
+
},
|
|
356
|
+
_removeElement() {
|
|
357
|
+
},
|
|
358
|
+
__clearAttributes() {
|
|
313
359
|
},
|
|
314
360
|
render() {
|
|
315
|
-
|
|
361
|
+
var p;
|
|
362
|
+
return this._ensureElement(), this._setData(), this.renderAttributes(), (p = this.updateSrc) == null || p.call(this), this;
|
|
316
363
|
}
|
|
317
364
|
});
|
|
318
|
-
|
|
365
|
+
c = new u({ el: s, config: m, model: n });
|
|
319
366
|
}
|
|
320
|
-
return
|
|
367
|
+
return c.el = s, c.render(), c;
|
|
321
368
|
}
|
|
322
|
-
function
|
|
369
|
+
function fe(e, t) {
|
|
323
370
|
const { Components: n } = e, s = (r) => {
|
|
324
|
-
const { id:
|
|
325
|
-
n.addType(
|
|
371
|
+
const { id: o, model: i } = r;
|
|
372
|
+
n.addType(o, {
|
|
326
373
|
model: {
|
|
327
374
|
toJSON(...c) {
|
|
328
|
-
const
|
|
329
|
-
return
|
|
375
|
+
const a = i.prototype.toJSON.apply(this, c);
|
|
376
|
+
return a.tagName = this.tagName, a;
|
|
330
377
|
}
|
|
331
378
|
}
|
|
332
379
|
});
|
|
333
380
|
};
|
|
334
|
-
n.getTypes().forEach(s), e.on("component:type:add", s), Object.entries(t.components || {}).forEach(([r,
|
|
335
|
-
var
|
|
381
|
+
n.getTypes().forEach(s), e.on("component:type:add", s), Object.entries(t.components || {}).forEach(([r, o]) => {
|
|
382
|
+
var m, u;
|
|
383
|
+
const { allowPropClassName: i, allowPropId: c, allowChildren: a } = o, f = !c && !i, l = () => ({
|
|
384
|
+
disabled: f
|
|
385
|
+
}), d = () => ({
|
|
386
|
+
disableClasses: !i,
|
|
387
|
+
disableComponent: !c
|
|
388
|
+
});
|
|
336
389
|
n.addType(r, {
|
|
337
|
-
isComponent: (
|
|
390
|
+
isComponent: (p) => (p == null ? void 0 : p.tagName) === r,
|
|
338
391
|
model: {
|
|
339
392
|
defaults: {
|
|
340
393
|
type: r,
|
|
341
|
-
traits:
|
|
342
|
-
|
|
394
|
+
traits: ((m = o.props) == null ? void 0 : m.call(o)) || [],
|
|
395
|
+
droppable: !!a,
|
|
396
|
+
stylable: !f,
|
|
397
|
+
styleManager: l,
|
|
398
|
+
selectorManager: d,
|
|
399
|
+
...((u = o.model) == null ? void 0 : u.defaults) || {}
|
|
343
400
|
}
|
|
344
401
|
}
|
|
345
402
|
});
|
|
346
403
|
});
|
|
347
404
|
}
|
|
348
|
-
function
|
|
349
|
-
var
|
|
350
|
-
const { component: t, config: n, editor: s, frameView: r, onMount:
|
|
351
|
-
|
|
352
|
-
if (!
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (
|
|
360
|
-
return /* @__PURE__ */
|
|
405
|
+
function W(e) {
|
|
406
|
+
var S;
|
|
407
|
+
const { component: t, config: n, editor: s, frameView: r, onMount: o, tagName: i, children: c } = e, { key: a, view: f, connectDom: l } = le(e);
|
|
408
|
+
_(() => {
|
|
409
|
+
if (!f && !o) return;
|
|
410
|
+
const g = setTimeout(() => {
|
|
411
|
+
f && (o == null || o(f), setTimeout(() => f.postRender()));
|
|
412
|
+
});
|
|
413
|
+
return () => clearTimeout(g);
|
|
414
|
+
}, [f]);
|
|
415
|
+
const d = t.get("type") || "default", m = t.content, u = (S = n.components) == null ? void 0 : S[d], p = (u == null ? void 0 : u.component) || i || t.tagName || "div", h = t.components(), b = h.length ? h.map((g) => /* @__PURE__ */ y(W, { component: g, config: n, editor: s, frameView: r }, g.cid)) : [m || void 0], C = se(t.getAttributes()), E = u == null ? void 0 : u.editorRender, A = [...b, c].filter((g) => g ?? !1), k = A.length ? A : null;
|
|
416
|
+
if (E)
|
|
417
|
+
return /* @__PURE__ */ y(E, { props: C, editor: s, component: t, connectDom: l, children: k });
|
|
418
|
+
if (u != null && u.component)
|
|
419
|
+
return /* @__PURE__ */ y("gjs-wrapper", { ref: l, style: u.wrapperStyle, children: /* @__PURE__ */ y(p, { ...C, children: k }) });
|
|
361
420
|
if (t.isInstanceOf("textnode"))
|
|
362
|
-
return
|
|
363
|
-
const
|
|
364
|
-
return /* @__PURE__ */
|
|
421
|
+
return m;
|
|
422
|
+
const B = t.isInstanceOf("text") ? a : void 0;
|
|
423
|
+
return /* @__PURE__ */ $(p, { ...C, ref: l, key: B }, t.get("void") ? null : k);
|
|
365
424
|
}
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
const { frame: t, window: n, onMount: s } = e, { root: r } = t;
|
|
425
|
+
const ue = (e) => {
|
|
426
|
+
const { frame: t, window: n, onMount: s, editor: r } = e, o = r.Canvas.events, { root: i } = t;
|
|
369
427
|
try {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
428
|
+
const c = j(n.document.body);
|
|
429
|
+
c.render(/* @__PURE__ */ y(de, { ...e, component: i, onMount: s }));
|
|
430
|
+
const a = () => c.unmount();
|
|
431
|
+
t.once(o.frameUnload, a), n.addEventListener("unload", a);
|
|
432
|
+
} catch (c) {
|
|
433
|
+
console.warn(c);
|
|
375
434
|
}
|
|
376
|
-
return
|
|
435
|
+
return i.getView();
|
|
377
436
|
};
|
|
378
|
-
function
|
|
379
|
-
const { editor: t, component: n, window: s, frameView: r, config:
|
|
380
|
-
return /* @__PURE__ */
|
|
381
|
-
|
|
437
|
+
function de(e) {
|
|
438
|
+
const { editor: t, component: n, window: s, frameView: r, config: o, onMount: i } = e, c = s.document, a = o.rootComponent || T, f = o.rootComponent ? { editorProps: { doc: c, editor: t, frameView: r } } : {}, l = (o == null ? void 0 : o.bodyAfter) || T;
|
|
439
|
+
return /* @__PURE__ */ y(a, { ...f, children: /* @__PURE__ */ y(
|
|
440
|
+
W,
|
|
382
441
|
{
|
|
383
442
|
tagName: "div",
|
|
384
443
|
component: n,
|
|
385
|
-
config:
|
|
444
|
+
config: o,
|
|
386
445
|
editor: t,
|
|
387
446
|
frameView: r,
|
|
388
|
-
onMount:
|
|
447
|
+
onMount: i,
|
|
448
|
+
children: /* @__PURE__ */ y(l, { ...f })
|
|
389
449
|
}
|
|
390
450
|
) });
|
|
391
451
|
}
|
|
392
|
-
const
|
|
393
|
-
|
|
452
|
+
const me = "rendererReact", ye = v.startup, he = function(e, t = {}) {
|
|
453
|
+
const { Blocks: n, Pages: s } = e, r = n.events, o = s.events;
|
|
454
|
+
e.Canvas.config.customRenderer = (c) => ue({ ...c, config: t }), e.Components.config.processor = (c) => w({ model: c, editor: e, config: t }), fe(e, t);
|
|
455
|
+
const i = [
|
|
456
|
+
[r.add, ie({ editor: e, config: t })],
|
|
457
|
+
[o.addBefore, ae({ editor: e, config: t })]
|
|
458
|
+
];
|
|
459
|
+
i.forEach(([c, a]) => e.on(c, a)), Q({
|
|
394
460
|
editor: e,
|
|
395
461
|
licenseKey: t.licenseKey,
|
|
396
|
-
plan:
|
|
397
|
-
pluginName:
|
|
462
|
+
plan: ye,
|
|
463
|
+
pluginName: me,
|
|
398
464
|
cleanup: () => {
|
|
399
|
-
e.Canvas.config.customRenderer = void 0;
|
|
465
|
+
e.Canvas.config.customRenderer = void 0, e.Components.config.processor = void 0, i.forEach(([c, a]) => e.off(c, a));
|
|
400
466
|
}
|
|
401
467
|
});
|
|
402
|
-
},
|
|
468
|
+
}, we = Z(he);
|
|
403
469
|
export {
|
|
404
|
-
|
|
470
|
+
we as default
|
|
405
471
|
};
|