@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,10 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`);return
|
|
3
|
-
${p}
|
|
4
|
-
}`:""},e=[],o={};this.rules.forEach(r=>{if(!r||!r.selectors||!r.style)return;const n=r.atRuleType&&r.mediaText?`@${r.atRuleType} ${r.mediaText}`:r.mediaText?`@media ${r.mediaText}`:null;n?(o[n]||(o[n]=[]),o[n].push(r)):e.push(r)});let a=e.map(r=>t(r)).join(`
|
|
5
|
-
`);return Object.keys(o).forEach(r=>{const n=o[r].map(l=>t(l)).join(`
|
|
6
|
-
`);n&&(a+=`
|
|
7
|
-
|
|
8
|
-
${r} {
|
|
9
|
-
${n}
|
|
10
|
-
}`)}),a}}class G{constructor(t){this.symbols=t}getAll(){return this.symbols}}class J{constructor(t){this.list=t}getAll(){return this.list}}class V{constructor(t){this.pages=t.map(e=>new L(e))}getAll(){return this.pages}}class _{constructor(t){this.assetManager=new q(t.assets||[]),this.cssComposer=new U(t.styles||[]),this.pages=new V(t.pages||[]),this.symbols=new G(t.symbols||[]),this.dataSources=new J(t.dataSources||[])}getAssetManager(){return this.assetManager}getCssComposer(){return this.cssComposer}getPages(){return this.pages}getSymbols(){return this.symbols}getDataSources(){return this.dataSources}}function x(s,t){if(s.getId()===t)return s;for(const e of s.getComponents()){const o=x(e,t);if(o)return o}return null}function H(s){var p;const{config:t,root:e,css:o}=s,a=t.wrapper||A.Fragment,r=e.getHead(),n=(p=e.getDocEl)==null?void 0:p.call(e),l=e.getAttributes().doctype||"<!DOCTYPE html>",d=(n==null?void 0:n.tagName)||"html",{skipDocType:u}=t;return i.jsxs(i.Fragment,{children:[u!==void 0&&!u&&l,i.jsxs(d,{children:[i.jsx(S,{component:r,config:t,children:i.jsx("style",{children:`${o}`})}),i.jsx(a,{children:i.jsx(S,{component:e,config:t})})]})]})}function m(s,t){const e=s?typeof s=="function"?s(t):s:"An error occurred";return i.jsx(i.Fragment,{children:i.jsx("html",{children:i.jsx("body",{children:e})})})}const K=({projectJson:s,config:t={},pageId:e,componentId:o})=>{var c;const a=new _(s),r=a.getCssComposer().getCssAsString(),n=a.getPages().getAll(),l={...E,...t.errors};if(!n.length)return m(l.noPagesFound,{projectJson:s});const d=e?n.find(h=>h.getName()===e):n[0];if(!d)return m(l.pageNotFound,{pageId:e});const u=d.getFrames();if(!u.length)return m(l.noFramesFound,{page:d});const p=(c=u[0])==null?void 0:c.getComponent();if(!p)return m(l.missingRootComponent,{frame:u[0]});if(o){const h=x(p,o);if(!h)return m(l.componentNotFound,{componentId:o});if(h){const y=t.wrapper||A.Fragment;return i.jsxs(i.Fragment,{children:[i.jsx("style",{children:`${r}`}),i.jsx(y,{children:i.jsx(S,{component:h,config:t})})]})}return null}return i.jsx(H,{config:t,root:p,css:r})};f.GrapesJSProject=K,f.RenderProjectComponent=S,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],a):(d=typeof globalThis<"u"?globalThis:d||self,a(d.StudioSdkPlugins_rendererReactProject={},d.jsxRuntime,d.React))})(this,function(d,a,y){"use strict";var g=(s=>(s.NoPagesFound="noPagesFound",s.PageNotFound="pageNotFound",s.NoFramesFound="noFramesFound",s.MissingRootComponent="missingRootComponent",s.ComponentNotFound="componentNotFound",s))(g||{});function k(s){const{config:t,errorType:e}=s,r=t==null?void 0:t.errorComponent;return r?a.jsx(r,{...s}):a.jsxs("div",{children:["Error: ",e]})}function b(s){const t={};let e=!1;for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const n=s[r];if(typeof n=="string"||typeof n=="number"){const o=r.includes("-")?r.replace(/-([a-z])/g,i=>i[1].toUpperCase()):r;t[o]=n,e=!0}}return e?t:void 0}function O(s){const t={};return s.split(";").forEach(e=>{if(!e.trim())return;const r=e.indexOf(":");if(r>0){const n=e.substring(0,r).trim(),o=e.substring(r+1).trim();if(n&&o){const i=n.replace(/-([a-z])/g,l=>l[1].toUpperCase());t[i]=o}}}),Object.keys(t).length>0?t:void 0}function D(s){if(s){if(typeof s=="object"&&!Array.isArray(s))return b(s);if(typeof s=="string"){let t=O(s);if(!t)try{const e=JSON.parse(s);typeof e=="object"&&e!==null&&!Array.isArray(e)&&(t=b(e))}catch(e){console.error("Failed to parse style string as JSON",e)}return t}if(Array.isArray(s)){const t={};return s.forEach(e=>{if(typeof e=="object"&&e!==null){const r=e.name||e.property,n=e.value;if(typeof r=="string"&&r&&n!==void 0&&n!==""){const o=r.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[o]=n}}}),Object.keys(t).length>0?t:void 0}}}function W(s){return N[s]?N[s]:s.includes("-")?s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase()):s}function B(s){var e;const t={};for(const[r,n]of Object.entries(s))if(r==="style")t.style=D(n);else if(r.startsWith("data-"))t[r]=n;else{const o=W(r);((e=s.xmlns)==null?void 0:e.includes("svg"))||s.viewBox!==void 0||s.d!==void 0||I.has(o)||o.startsWith("svg")?t[o]=n:!M.has(o)&&!o.startsWith("on")&&!o.startsWith("aria-")&&!o.startsWith("data-")?t[r]=n:t[o]=n}return t}const M=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"]),I=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"]),N={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"};function z(s,t,e){const{id:r,type:n}=s,o=r||void 0;let i;return r?i=r:t?i=`${t}-${e??0}`:n==="head"?i="gjs-head":t==="gjs-head"?i=`${t}-${e??0}`:i=`gjs-${n}`,{key:i,nodeId:o}}const F=function s(t){var T;const{component:e,config:r,children:n,parentId:o,index:i}=t;if(!e)return null;const{type:l,content:c}=e;if(l==="textnode")return c;const u=(T=r==null?void 0:r.components)==null?void 0:T[l],f=(u==null?void 0:u.component)||e.tagName||"div",h=e.attributes,{key:S,nodeId:$}=z(e,o,i),j=!!(u!=null&&u.component),C=B(h);j&&Object.keys(C).forEach(A=>{const p=C[A];typeof p=="string"&&!isNaN(Number(p))&&p.trim()!==""&&(C[A]=Number(p))});const{components:w}=e,R=[...w.length?w.map((A,p)=>a.jsx(s,{config:r,component:A,parentId:S,index:p},`${A.id}-${p}`)):[c],n],E={...C,...$?{id:$}:{}};return j?a.jsx(f,{...E,children:R},S):y.createElement(f,{...E,key:S},e.isVoid?null:R)};function L(s){var c;const{config:t,root:e,css:r}=s,n=(t==null?void 0:t.rootComponent)||y.Fragment,o=((c=e.docEl)==null?void 0:c.tagName)||"html",i=(t==null?void 0:t.headAfter)||y.Fragment,l=(t==null?void 0:t.bodyAfter)||y.Fragment;return a.jsx(o,{children:a.jsxs(n,{children:[a.jsxs(F,{component:e.head,config:t,children:[a.jsx("style",{children:`${r}`}),a.jsx(i,{})]}),a.jsx(F,{component:e,config:t,children:a.jsx(l,{})})]})})}class v{constructor(t){this.data=t}get id(){var t;return(t=this.data.attributes)==null?void 0:t.id}get type(){return this.data.type||"default"}get tagName(){const{type:t}=this;return t==="svg"?"svg":t==="image"?"img":t==="linkBox"||t==="link"?"a":t==="head"?"head":t==="wrapper"?"body":this.data.tagName||""}get isVoid(){return this.tagName==="img"?!0:!!this.data.void}get attributes(){const t={...this.data.attributes},{classes:e}=this;e.length&&(t.class=e.join(" "));function r(n,o){return Object.prototype.hasOwnProperty.call(n,o)}return r(t,"id")||(t.id=this.id),t}get content(){return this.data.content||""}get components(){return(this.data.components||[]).map(t=>new v(t))}get head(){return new v(this.data.head||{tagName:"head"})}get docEl(){return this.data.docEl}get classes(){return(this.data.classes||[]).map(e=>typeof e=="string"?e:e.name)}}class _{constructor(t){this.data=t}get component(){return this.data.component?new v(this.data.component):null}}class U{constructor(t){this.data=t}get id(){return this.data.id}get frames(){return(this.data.frames||[]).map(t=>new _(t))}}function x(s){const t=/(-?\d*\.?\d+)\w{0,}/.exec(s);return t?parseFloat(t[1]):Number.MAX_VALUE}class q{constructor(t){this.rules=t}getAll(){return this.rules}getRulesByGroup(t){return this.rules.filter(e=>e.group===t)}getAtRule(t){const{atRuleType:e,mediaText:r}=t,n=e?`@${e}`:r?"@media":"";return n+(r&&n?` ${r}`:"")}selectorsToString(t,e={}){const r=[],{state:n,selectorsAdd:o,selectors:i=[]}=t,l=i.map(u=>this.getFromSelectorName(u)).join(""),c=n&&!e.skipState?`:${n}`:"";return l&&r.push(`${l}${c}`),o&&!e.skipAdd&&r.push(o),r.join(", ")}getFromSelectorName(t=""){return`${t.startsWith("#")?"":"."}${t}`}styleToString(t={}){const e=[],{style:r={},important:n}=t;for(const o in r){const i=Array.isArray(n)?n.indexOf(o)>=0:n;if(o.substring(0,2)==="__")continue;const c=r[o];(Array.isArray(c)?c:[c]).forEach(m=>{const f=`${m}${i?" !important":""}`;f&&e.push(`${o}:${f};`)})}return e.join("")}getDeclaration(t){const{singleAtRule:e}=t,r=this.selectorsToString(t),n=this.styleToString(t);let o="";return(r||e)&&n&&(o=e?n:`${r}{${n}}`),o}buildFromRule(t){let e="";const r=this.selectorsToString(t),{selectorsAdd:n,singleAtRule:o}=t;if(r||n||o){const i=this.getDeclaration(t);i&&(e+=i)}return e}sortMediaObject(t={}){const e=[];for(const r in t){const n=t[r];e.push({key:r,value:n})}return e.sort((r,n)=>{const o=[r.key,n.key].every(c=>c.indexOf("min-width")!==-1),i=o?r.key:n.key,l=o?n.key:r.key;return x(i)-x(l)})}getCssAsString(){if(!this.rules||!this.rules.length)return"";const{rules:t}=this,e={},r=[];return t.forEach(n=>{const o=this.getAtRule(n);if(o){const i=e[o];i?i.push(n):e[o]=[n];return}r.push(this.buildFromRule(n))}),this.sortMediaObject(e).forEach(n=>{let o="";const i=n.key;n.value.forEach(c=>{const u=this.buildFromRule(c);c.singleAtRule?r.push(`${i}{${u}}`):o+=u}),o&&r.push(`${i}{${o}}`)}),r.join(`
|
|
2
|
+
`)}}class V{constructor(t){this.list=t}getAll(){return this.list}}class J{constructor(t){this.pages=t.map(e=>new U(e))}getAll(){return this.pages}}class K{constructor(t){this.Css=new q(t.styles||[]),this.Pages=new J(t.pages||[]),this.DataSources=new V(t.dataSources||[])}}function P(s,t){if(s.id===t)return s;for(const e of s.components){const r=P(e,t);if(r)return r}return null}const G=function(s){var f;const{projectData:t,config:e={},pageId:r,componentId:n}=s,o=new K(t),i=o.Css.getCssAsString(),l=o.Pages.getAll();if(!l.length)return a.jsx(k,{...s,errorType:g.NoPagesFound});const c=r?l.find(h=>h.id===r):l[0];if(!c)return a.jsx(k,{...s,errorType:g.PageNotFound});const{frames:u}=c;if(!u.length)return a.jsx(k,{...s,errorType:g.NoFramesFound});const m=(f=u[0])==null?void 0:f.component;if(!m)return a.jsx(k,{...s,errorType:g.MissingRootComponent});if(n){const h=P(m,n);if(!h)return a.jsx(k,{...s,errorType:g.ComponentNotFound});if(h){const S=e.rootComponent||y.Fragment;return a.jsxs(S,{children:[a.jsx("style",{children:`${i}`}),a.jsx(F,{component:h,config:e})]})}return null}return a.jsx(L,{config:e,root:m,css:i})};d.RenderProject=G,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
+
import { CssRuleProperties } from 'grapesjs';
|
|
1
2
|
export interface Asset {
|
|
2
3
|
type?: string;
|
|
3
4
|
src?: string;
|
|
4
5
|
unitDim?: string;
|
|
5
6
|
height?: number;
|
|
6
7
|
width?: number;
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}
|
|
9
|
-
export interface Rule {
|
|
10
|
-
selectors?: string[] | string;
|
|
11
|
-
style?: Record<string, any>;
|
|
12
|
-
mediaText?: string;
|
|
13
|
-
atRuleType?: string;
|
|
14
|
-
state?: string;
|
|
15
|
-
group?: string;
|
|
16
|
-
wrapper?: number;
|
|
17
|
-
[key: string]: any;
|
|
18
8
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
9
|
+
export interface Rule extends Omit<CssRuleProperties, 'selectors'> {
|
|
10
|
+
selectors?: string[];
|
|
21
11
|
}
|
|
22
12
|
export interface DataSource {
|
|
23
13
|
[key: string]: any;
|
|
@@ -30,6 +20,7 @@ export interface DocElDefinition {
|
|
|
30
20
|
tagName?: string;
|
|
31
21
|
[key: string]: any;
|
|
32
22
|
}
|
|
23
|
+
type AtRules = Record<string, Rule[]>;
|
|
33
24
|
export interface ComponentDefinition {
|
|
34
25
|
id?: string;
|
|
35
26
|
type?: string;
|
|
@@ -62,58 +53,54 @@ export interface ProjectDefinition {
|
|
|
62
53
|
assets?: Asset[];
|
|
63
54
|
styles?: Rule[];
|
|
64
55
|
pages?: PageDefinition[];
|
|
65
|
-
symbols?: SymbolData[];
|
|
66
56
|
dataSources?: DataSource[];
|
|
67
57
|
[key: string]: any;
|
|
68
58
|
}
|
|
69
59
|
export declare class ComponentNode {
|
|
70
60
|
private data;
|
|
71
61
|
constructor(data: ComponentDefinition);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
isVoid(): boolean;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
getClasses(): string[];
|
|
83
|
-
hasClass(className: string): boolean;
|
|
62
|
+
get id(): string | undefined;
|
|
63
|
+
get type(): string;
|
|
64
|
+
get tagName(): string;
|
|
65
|
+
get isVoid(): boolean;
|
|
66
|
+
get attributes(): Record<string, any>;
|
|
67
|
+
get content(): string;
|
|
68
|
+
get components(): ComponentNode[];
|
|
69
|
+
get head(): ComponentNode;
|
|
70
|
+
get docEl(): DocElDefinition | undefined;
|
|
71
|
+
get classes(): string[];
|
|
84
72
|
}
|
|
85
73
|
export declare class Frame {
|
|
86
74
|
private data;
|
|
87
75
|
constructor(data: FrameDefinition);
|
|
88
|
-
|
|
89
|
-
getWidth(): string;
|
|
90
|
-
getHeight(): string;
|
|
76
|
+
get component(): ComponentNode | null;
|
|
91
77
|
}
|
|
92
78
|
export declare class Page {
|
|
93
79
|
private data;
|
|
94
80
|
constructor(data: PageDefinition);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
getFrames(): Frame[];
|
|
98
|
-
}
|
|
99
|
-
export declare class AssetManager {
|
|
100
|
-
private assets;
|
|
101
|
-
constructor(assets: Asset[]);
|
|
102
|
-
getAll(): Asset[];
|
|
81
|
+
get id(): string;
|
|
82
|
+
get frames(): Frame[];
|
|
103
83
|
}
|
|
104
84
|
export declare class CssComposer {
|
|
105
85
|
private rules;
|
|
106
86
|
constructor(rules: Rule[]);
|
|
107
87
|
getAll(): Rule[];
|
|
108
88
|
getRulesByGroup(g: string): Rule[];
|
|
109
|
-
|
|
89
|
+
getAtRule(rule: Rule): string;
|
|
90
|
+
selectorsToString(rule: Rule, opts?: {
|
|
91
|
+
skipState?: boolean;
|
|
92
|
+
skipAdd?: boolean;
|
|
93
|
+
}): string;
|
|
94
|
+
getFromSelectorName(selector?: string): string;
|
|
95
|
+
styleToString(rule?: Rule): string;
|
|
96
|
+
getDeclaration(rule: Rule): string;
|
|
97
|
+
buildFromRule(rule: Rule): string;
|
|
98
|
+
sortMediaObject(items?: AtRules): {
|
|
99
|
+
key: string;
|
|
100
|
+
value: Rule[];
|
|
101
|
+
}[];
|
|
110
102
|
getCssAsString(): string;
|
|
111
103
|
}
|
|
112
|
-
export declare class SymbolsManager {
|
|
113
|
-
private symbols;
|
|
114
|
-
constructor(symbols: SymbolData[]);
|
|
115
|
-
getAll(): SymbolData[];
|
|
116
|
-
}
|
|
117
104
|
export declare class DataSourceManager {
|
|
118
105
|
private list;
|
|
119
106
|
constructor(list: DataSource[]);
|
|
@@ -125,16 +112,10 @@ export declare class Pages {
|
|
|
125
112
|
getAll(): Page[];
|
|
126
113
|
}
|
|
127
114
|
export declare class Editor {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
private symbols;
|
|
132
|
-
private dataSources;
|
|
115
|
+
Css: CssComposer;
|
|
116
|
+
Pages: Pages;
|
|
117
|
+
DataSources: DataSourceManager;
|
|
133
118
|
constructor(data: ProjectDefinition);
|
|
134
|
-
getAssetManager(): AssetManager;
|
|
135
|
-
getCssComposer(): CssComposer;
|
|
136
|
-
getPages(): Pages;
|
|
137
|
-
getSymbols(): SymbolsManager;
|
|
138
|
-
getDataSources(): DataSourceManager;
|
|
139
119
|
}
|
|
140
120
|
export declare function findComponentById(root: ComponentNode, id: string): ComponentNode | null;
|
|
121
|
+
export {};
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { ProjectData } from 'grapesjs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { RendererReactOptions } from '../shared/types';
|
|
4
|
+
import { ComponentNode } from './parser/parser';
|
|
5
|
+
export interface RenderCommonProps {
|
|
6
|
+
config?: RendererReactOptions;
|
|
7
|
+
}
|
|
8
|
+
export interface RenderProjectProps extends RenderCommonProps {
|
|
9
|
+
projectData: ProjectData;
|
|
6
10
|
pageId?: string;
|
|
7
11
|
componentId?: string;
|
|
8
12
|
}
|
|
13
|
+
export interface RenderPageProps extends RenderCommonProps {
|
|
14
|
+
root: ComponentNode;
|
|
15
|
+
css: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RenderComponentProps extends RenderCommonProps {
|
|
18
|
+
component: ComponentNode;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
parentId?: string;
|
|
21
|
+
index?: number;
|
|
22
|
+
}
|
|
@@ -3,14 +3,3 @@ export declare function getComponentId(component: ComponentNode, parentId?: stri
|
|
|
3
3
|
key: string;
|
|
4
4
|
nodeId: string | undefined;
|
|
5
5
|
};
|
|
6
|
-
export declare const defaultErrors: {
|
|
7
|
-
noPagesFound: () => string;
|
|
8
|
-
pageNotFound: ({ pageId }: {
|
|
9
|
-
pageId?: string;
|
|
10
|
-
}) => string;
|
|
11
|
-
noFramesFound: () => string;
|
|
12
|
-
missingRootComponent: () => string;
|
|
13
|
-
componentNotFound: ({ componentId }: {
|
|
14
|
-
componentId: string;
|
|
15
|
-
}) => string;
|
|
16
|
-
};
|
|
@@ -1,49 +1,155 @@
|
|
|
1
|
-
import { Component, ComponentDefinitionDefined, Editor,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Component, ComponentDefinitionDefined, CustomRendererProps, Editor, TraitProperties } from 'grapesjs';
|
|
2
|
+
import { ComponentType, ReactElement, ReactNode, Ref, CSSProperties } from 'react';
|
|
3
|
+
import { RenderProjectProps } from '../rendererProject/types';
|
|
4
|
+
import { ComponentConfigSchema, ErrorType, RendererReactOptionsSchema } from '../typesSchema';
|
|
5
|
+
declare module 'grapesjs' {
|
|
6
|
+
interface BlockProperties {
|
|
7
|
+
content?: ContentType | (() => ContentType) | ReactElement<any, any>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export type EditorRenderProps = (props: {
|
|
11
|
+
props: Record<string, any>;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
editor: Editor;
|
|
14
|
+
component: Component;
|
|
15
|
+
connectDom: Ref<any>;
|
|
16
|
+
}) => ReactElement;
|
|
17
|
+
export interface ComponentConfig extends Omit<ComponentConfigSchema, 'component' | 'props' | 'model' | 'wrapperStyle' | 'editorRender'> {
|
|
18
|
+
/**
|
|
19
|
+
* React Component
|
|
20
|
+
* @example
|
|
21
|
+
* component: ({ id, className, children, title, ...rest }) => {
|
|
22
|
+
* return (
|
|
23
|
+
* <div id={id} className={className} {...rest}>
|
|
24
|
+
* <h1>{title}</h1>
|
|
25
|
+
* {children}
|
|
26
|
+
* </div>
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
component: ComponentType<any>;
|
|
31
|
+
/**
|
|
32
|
+
* Return an array of properties in a shape of GrapesJS traits.
|
|
33
|
+
* @example
|
|
34
|
+
* props: () => [
|
|
35
|
+
* {
|
|
36
|
+
* type: 'text',
|
|
37
|
+
* name: 'title',
|
|
38
|
+
* label: 'Title',
|
|
39
|
+
* }
|
|
40
|
+
* ]
|
|
41
|
+
*/
|
|
42
|
+
props?: () => TraitProperties[];
|
|
43
|
+
/**
|
|
44
|
+
* GrapesJS component model definition.
|
|
45
|
+
* @example
|
|
46
|
+
* model: {
|
|
47
|
+
* defaults: {
|
|
48
|
+
* draggable: false,
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
10
52
|
model?: ComponentDefinitionDefined;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Allows you to customize the style of the wrapper element around your React component.
|
|
55
|
+
*
|
|
56
|
+
* In the editor, all React components are automatically wrapped in a container element.
|
|
57
|
+
* This wrapper enables editing features like drag & drop, selection, and more.
|
|
58
|
+
*
|
|
59
|
+
* For most cases, styling the wrapper is sufficient. If you need deeper customization
|
|
60
|
+
* (e.g., changing the wrapper element type or structure), use the `editorRender` option instead.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* wrapperStyle: { display: 'block' }
|
|
64
|
+
*/
|
|
65
|
+
wrapperStyle?: CSSProperties;
|
|
66
|
+
/**
|
|
67
|
+
* Custom render function for displaying the component inside the editor canvas.
|
|
68
|
+
*
|
|
69
|
+
* Use this when you want full control over how the component appears in the editor,
|
|
70
|
+
* including custom wrappers, helper elements, or injected behavior.
|
|
71
|
+
*
|
|
72
|
+
* The `connectDom` function must be passed to the element that should be treated as the
|
|
73
|
+
* component root (for selection, dragging, etc.).
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* component: MyComponent,
|
|
77
|
+
* editorRender: ({ connectDom, editor, component, children, props }) => {
|
|
78
|
+
* return (
|
|
79
|
+
* <div ref={connectDom}>
|
|
80
|
+
* <div>Custom render of the component in the editor canvas</div>
|
|
81
|
+
* <MyComponent {...props}>{children}</MyComponent>
|
|
82
|
+
* </div>
|
|
83
|
+
* )
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
editorRender?: EditorRenderProps;
|
|
87
|
+
}
|
|
88
|
+
export interface RenderErrorProps extends RenderProjectProps {
|
|
89
|
+
errorType: ErrorType;
|
|
90
|
+
}
|
|
91
|
+
export interface EditorProps {
|
|
92
|
+
doc: Document;
|
|
93
|
+
editor: Editor;
|
|
94
|
+
frameView: CustomRendererProps['frameView'];
|
|
18
95
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
noFramesFound: ObjectAny;
|
|
25
|
-
missingRootComponent: ObjectAny;
|
|
26
|
-
componentNotFound: {
|
|
27
|
-
componentId: string;
|
|
28
|
-
};
|
|
96
|
+
export interface WithEditorProps {
|
|
97
|
+
/**
|
|
98
|
+
* Properties passed only during the rendering in the editor.
|
|
99
|
+
*/
|
|
100
|
+
editorProps?: EditorProps;
|
|
29
101
|
}
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
[K in keyof ErrorParams]?: ErrorHandler<K>;
|
|
33
|
-
};
|
|
34
|
-
export interface WrapperProps {
|
|
35
|
-
children?: React.ReactNode;
|
|
36
|
-
editorProps?: {
|
|
37
|
-
doc: Document;
|
|
38
|
-
editor: unknown;
|
|
39
|
-
frameView: unknown;
|
|
40
|
-
};
|
|
102
|
+
export interface RootComponentProps extends WithEditorProps {
|
|
103
|
+
children?: ReactNode;
|
|
41
104
|
}
|
|
42
|
-
export interface
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
105
|
+
export interface RendererReactOptions extends Omit<RendererReactOptionsSchema, 'components' | 'errorComponent' | 'rootComponent' | 'headAfter' | 'bodyAfter'> {
|
|
106
|
+
/**
|
|
107
|
+
* Map of custom components.
|
|
108
|
+
* @example
|
|
109
|
+
* components: {
|
|
110
|
+
* MyComponent: {
|
|
111
|
+
* allowPropId: true,
|
|
112
|
+
* allowPropClassName: true,
|
|
113
|
+
* allowChildren: true,
|
|
114
|
+
* component: ({ id, className, children, title, ...rest }) => {
|
|
115
|
+
* return (
|
|
116
|
+
* <div id={id} className={className} {...rest}>
|
|
117
|
+
* <h1>{title}</h1>
|
|
118
|
+
* {children}
|
|
119
|
+
* </div>
|
|
120
|
+
* )
|
|
121
|
+
* },
|
|
122
|
+
* }
|
|
123
|
+
* }
|
|
124
|
+
*/
|
|
125
|
+
components?: Record<string, ComponentConfig>;
|
|
126
|
+
/**
|
|
127
|
+
* Custom error component.
|
|
128
|
+
* This is used when, for example, you're trying to render a page with an invalid id.
|
|
129
|
+
* @example
|
|
130
|
+
* errorComponent: ({ errorType }) => <div>Error: {errorType}</div>
|
|
131
|
+
*/
|
|
132
|
+
errorComponent?: ComponentType<RenderErrorProps>;
|
|
133
|
+
/**
|
|
134
|
+
* Custom root component that wraps the entire rendered project.
|
|
135
|
+
* Usually used to provide a layout or context for the entire application.
|
|
136
|
+
* @example
|
|
137
|
+
* rootComponent: ({ children }) => <div>{children}</div>
|
|
138
|
+
*/
|
|
139
|
+
rootComponent?: ComponentType<RootComponentProps>;
|
|
140
|
+
/**
|
|
141
|
+
* Custom react component to append at the end of the `<head>` element.
|
|
142
|
+
* @example
|
|
143
|
+
* headAfter: () => (<>
|
|
144
|
+
* <meta/>
|
|
145
|
+
* <script src="path/to/analytics.js"></script>
|
|
146
|
+
* </>)
|
|
147
|
+
*/
|
|
148
|
+
headAfter?: ComponentType<WithEditorProps>;
|
|
149
|
+
/**
|
|
150
|
+
* Custom react component to append at the end of the `<body>` element.
|
|
151
|
+
* @example
|
|
152
|
+
* bodyAfter: () => <div>Powered by MyApp</div>
|
|
153
|
+
*/
|
|
154
|
+
bodyAfter?: ComponentType<WithEditorProps>;
|
|
49
155
|
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { RendererReactOptions } from './types';
|
|
2
|
+
export declare function fromCamelCaseToKebab(style: Record<string, string | number>): Record<string, string | number>;
|
|
3
|
+
export declare const getComponentConfig: (config: RendererReactOptions, reactComponent: React.ComponentType<any>) => {
|
|
4
|
+
cmpConfig: import('./types').ComponentConfig;
|
|
5
|
+
type: string;
|
|
6
|
+
} | undefined;
|
|
1
7
|
export declare function normalizeStyleObject(styleObj: any): React.CSSProperties | undefined;
|
|
2
|
-
export declare function
|
|
8
|
+
export declare function attrsToReactProps(attrs: Record<string, any>): Record<string, any>;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ReactRendererPluginOptionsSchema } from './typesSchema';
|
|
1
|
+
import { CustomRendererProps } from 'grapesjs';
|
|
2
|
+
import { RenderCanvasComponentProps } from './rendererCanvas/RenderCanvasComponent';
|
|
3
|
+
import { RendererReactOptions } from './shared/types';
|
|
5
4
|
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
__reactRoot?: ReturnType<typeof createRoot>;
|
|
8
|
-
}
|
|
9
5
|
namespace JSX {
|
|
10
6
|
interface IntrinsicElements {
|
|
11
7
|
'gjs-wrapper': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
12
8
|
}
|
|
13
9
|
}
|
|
14
10
|
}
|
|
15
|
-
type
|
|
16
|
-
export
|
|
17
|
-
|
|
11
|
+
export type * from './shared/types';
|
|
12
|
+
export type { RendererReactOptions } from './shared/types';
|
|
13
|
+
export interface CustomRendererPropsWithConfig extends CustomRendererProps {
|
|
14
|
+
config: RendererReactOptions;
|
|
18
15
|
}
|
|
19
|
-
export interface
|
|
16
|
+
export interface RenderRootProps extends Omit<RenderCanvasComponentProps, 'component'>, Pick<CustomRendererPropsWithConfig, 'window'> {
|
|
17
|
+
component: CustomRendererProps['frame']['root'];
|
|
20
18
|
}
|
|
21
|
-
export {};
|