@builder.io/sdk-solid 0.0.8-0 → 0.0.8-11
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/package.json +11 -6
- package/src/blocks/button/button.jsx +1 -1
- package/src/blocks/button/button.lite.tsx +4 -1
- package/src/blocks/columns/columns.jsx +3 -3
- package/src/blocks/columns/columns.lite.tsx +30 -23
- package/src/blocks/custom-code/custom-code.jsx +1 -0
- package/src/blocks/custom-code/custom-code.lite.tsx +2 -0
- package/src/blocks/embed/embed.jsx +2 -1
- package/src/blocks/embed/embed.lite.tsx +3 -1
- package/src/blocks/form/form.jsx +1 -1
- package/src/blocks/form/form.lite.tsx +8 -5
- package/src/blocks/image/image.jsx +3 -3
- package/src/blocks/image/image.lite.tsx +10 -7
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.jsx +2 -1
- package/src/blocks/symbol/symbol.lite.tsx +3 -1
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/text/text.lite.tsx +1 -1
- package/src/components/render-block/block-styles.jsx +18 -3
- package/src/components/render-block/block-styles.lite.tsx +21 -3
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +48 -31
- package/src/components/render-block/render-block.lite.tsx +74 -37
- package/src/components/render-block/render-component.jsx +27 -0
- package/src/components/render-block/render-component.lite.tsx +38 -0
- package/src/components/render-blocks.jsx +11 -1
- package/src/components/render-blocks.lite.tsx +20 -1
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +32 -7
- package/src/components/render-content/render-content.lite.tsx +45 -15
- package/src/components/render-inlined-styles.jsx +2 -1
- package/src/components/render-inlined-styles.lite.tsx +4 -1
- package/src/constants/builder-registered-components.js +45 -0
- package/src/context/builder.context.js +2 -1
- package/src/functions/fast-clone.js +4 -0
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +2 -2
- package/src/functions/register-component.js +30 -13
- package/src/index-helpers/blocks-exports.js +9 -9
- package/src/solid-index.jsx +5 -0
- package/src/types/components.js +0 -0
- package/src/types/element.js +0 -0
- package/src/blocks/button/index.js +0 -7
- package/src/blocks/columns/index.js +0 -7
- package/src/blocks/custom-code/index.js +0 -7
- package/src/blocks/embed/index.js +0 -7
- package/src/blocks/form/index.js +0 -7
- package/src/blocks/fragment/index.js +0 -7
- package/src/blocks/image/index.js +0 -7
- package/src/blocks/img/index.js +0 -7
- package/src/blocks/input/index.js +0 -7
- package/src/blocks/raw-text/index.js +0 -7
- package/src/blocks/section/index.js +0 -7
- package/src/blocks/select/index.js +0 -7
- package/src/blocks/submit-button/index.js +0 -7
- package/src/blocks/symbol/index.js +0 -7
- package/src/blocks/text/index.js +0 -7
- package/src/blocks/textarea/index.js +0 -7
- package/src/blocks/video/index.js +0 -7
- package/src/functions/macro-eval.js +0 -5
|
@@ -2,7 +2,6 @@ import { useContext, Show, For } from "solid-js";
|
|
|
2
2
|
import { Dynamic } from "solid-js/web";
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
4
|
|
|
5
|
-
import { TARGET } from "../../constants/target.js";
|
|
6
5
|
import BuilderContext from "../../context/builder.context";
|
|
7
6
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
8
7
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
@@ -10,8 +9,9 @@ import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
|
10
9
|
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
11
10
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
12
11
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
13
|
-
import { components } from "../../functions/register-component.js";
|
|
14
12
|
import BlockStyles from "./block-styles.lite";
|
|
13
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
14
|
+
import RenderComponent from "./render-component.lite";
|
|
15
15
|
|
|
16
16
|
function RenderBlock(props) {
|
|
17
17
|
const state = createMutable({
|
|
@@ -22,19 +22,25 @@ function RenderBlock(props) {
|
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const ref =
|
|
25
|
+
const ref = builderContext.registeredComponents[componentName];
|
|
26
26
|
|
|
27
|
-
if (
|
|
27
|
+
if (!ref) {
|
|
28
28
|
// TODO: Public doc page with more info about this message
|
|
29
29
|
console.warn(`
|
|
30
30
|
Could not find a registered component named "${componentName}".
|
|
31
31
|
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
32
|
+
return undefined;
|
|
33
|
+
} else {
|
|
34
|
+
return ref;
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
return ref;
|
|
35
36
|
},
|
|
36
37
|
get componentInfo() {
|
|
37
|
-
|
|
38
|
+
if (state.component) {
|
|
39
|
+
const { component: _, ...info } = state.component;
|
|
40
|
+
return info;
|
|
41
|
+
} else {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
38
44
|
},
|
|
39
45
|
get componentRef() {
|
|
40
46
|
return state.component?.component;
|
|
@@ -49,7 +55,7 @@ function RenderBlock(props) {
|
|
|
49
55
|
context: builderContext.context,
|
|
50
56
|
});
|
|
51
57
|
},
|
|
52
|
-
get
|
|
58
|
+
get attributes() {
|
|
53
59
|
return {
|
|
54
60
|
...getBlockProperties(state.useBlock),
|
|
55
61
|
...getBlockActions({
|
|
@@ -57,13 +63,26 @@ function RenderBlock(props) {
|
|
|
57
63
|
state: builderContext.state,
|
|
58
64
|
context: builderContext.context,
|
|
59
65
|
}),
|
|
66
|
+
style: getBlockStyles(state.useBlock),
|
|
60
67
|
};
|
|
61
68
|
},
|
|
62
|
-
get
|
|
63
|
-
return
|
|
69
|
+
get shouldWrap() {
|
|
70
|
+
return !state.componentInfo?.noWrap;
|
|
64
71
|
},
|
|
65
72
|
get componentOptions() {
|
|
66
|
-
return
|
|
73
|
+
return {
|
|
74
|
+
...getBlockComponentOptions(state.useBlock),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
78
|
+
* they are provided to the component itself directly.
|
|
79
|
+
*/
|
|
80
|
+
...(state.shouldWrap
|
|
81
|
+
? {}
|
|
82
|
+
: {
|
|
83
|
+
attributes: state.attributes,
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
67
86
|
},
|
|
68
87
|
get children() {
|
|
69
88
|
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
@@ -73,6 +92,10 @@ function RenderBlock(props) {
|
|
|
73
92
|
return state.useBlock.children ?? [];
|
|
74
93
|
},
|
|
75
94
|
get noCompRefChildren() {
|
|
95
|
+
/**
|
|
96
|
+
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
97
|
+
* we render them outside of `componentRef`
|
|
98
|
+
*/
|
|
76
99
|
return state.componentRef ? [] : state.children;
|
|
77
100
|
},
|
|
78
101
|
});
|
|
@@ -80,39 +103,53 @@ function RenderBlock(props) {
|
|
|
80
103
|
const builderContext = useContext(BuilderContext);
|
|
81
104
|
|
|
82
105
|
return (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
<Show
|
|
107
|
+
fallback={
|
|
108
|
+
<RenderComponent
|
|
109
|
+
blockChildren={state.children}
|
|
110
|
+
componentRef={state.componentRef}
|
|
111
|
+
componentOptions={state.componentOptions}
|
|
112
|
+
></RenderComponent>
|
|
113
|
+
}
|
|
114
|
+
when={state.shouldWrap}
|
|
115
|
+
>
|
|
116
|
+
<Show
|
|
117
|
+
fallback={
|
|
118
|
+
<Dynamic {...state.attributes} component={state.tagName}></Dynamic>
|
|
119
|
+
}
|
|
120
|
+
when={!isEmptyHtmlElement(state.tagName)}
|
|
121
|
+
>
|
|
122
|
+
<Dynamic {...state.attributes} component={state.tagName}>
|
|
123
|
+
<RenderComponent
|
|
124
|
+
blockChildren={state.children}
|
|
125
|
+
componentRef={state.componentRef}
|
|
126
|
+
componentOptions={state.componentOptions}
|
|
127
|
+
></RenderComponent>
|
|
128
|
+
<For each={state.noCompRefChildren}>
|
|
129
|
+
{(child, _index) => {
|
|
130
|
+
const index = _index();
|
|
131
|
+
return (
|
|
132
|
+
<RenderBlock
|
|
133
|
+
key={"render-block-" + child.id}
|
|
134
|
+
block={child}
|
|
135
|
+
></RenderBlock>
|
|
136
|
+
);
|
|
137
|
+
}}
|
|
138
|
+
</For>
|
|
107
139
|
<For each={state.noCompRefChildren}>
|
|
108
140
|
{(child, _index) => {
|
|
109
141
|
const index = _index();
|
|
110
|
-
return
|
|
142
|
+
return (
|
|
143
|
+
<BlockStyles
|
|
144
|
+
key={"block-style-" + child.id}
|
|
145
|
+
block={child}
|
|
146
|
+
></BlockStyles>
|
|
147
|
+
);
|
|
111
148
|
}}
|
|
112
149
|
</For>
|
|
113
150
|
</Dynamic>
|
|
114
151
|
</Show>
|
|
115
|
-
|
|
152
|
+
</Show>
|
|
116
153
|
);
|
|
117
154
|
}
|
|
118
155
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Show, For } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
3
|
+
import BlockStyles from "./block-styles";
|
|
4
|
+
import RenderBlock from "./render-block";
|
|
5
|
+
|
|
6
|
+
function RenderComponent(props) {
|
|
7
|
+
return <Show when={props.componentRef}>
|
|
8
|
+
<Dynamic {...props.componentOptions} component={props.componentRef}>
|
|
9
|
+
<For each={props.blockChildren}>
|
|
10
|
+
{(child, _index) => {
|
|
11
|
+
const index = _index();
|
|
12
|
+
|
|
13
|
+
return <RenderBlock key={"render-block-" + child.id} block={child}></RenderBlock>;
|
|
14
|
+
}}
|
|
15
|
+
</For>
|
|
16
|
+
<For each={props.blockChildren}>
|
|
17
|
+
{(child, _index) => {
|
|
18
|
+
const index = _index();
|
|
19
|
+
|
|
20
|
+
return <BlockStyles key={"block-style-" + child.id} block={child}></BlockStyles>;
|
|
21
|
+
}}
|
|
22
|
+
</For>
|
|
23
|
+
</Dynamic>
|
|
24
|
+
</Show>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default RenderComponent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Show, For } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
3
|
+
|
|
4
|
+
import BlockStyles from "./block-styles.lite";
|
|
5
|
+
import RenderBlock from "./render-block.lite";
|
|
6
|
+
|
|
7
|
+
function RenderComponent(props) {
|
|
8
|
+
return (
|
|
9
|
+
<Show when={props.componentRef}>
|
|
10
|
+
<Dynamic {...props.componentOptions} component={props.componentRef}>
|
|
11
|
+
<For each={props.blockChildren}>
|
|
12
|
+
{(child, _index) => {
|
|
13
|
+
const index = _index();
|
|
14
|
+
return (
|
|
15
|
+
<RenderBlock
|
|
16
|
+
key={"render-block-" + child.id}
|
|
17
|
+
block={child}
|
|
18
|
+
></RenderBlock>
|
|
19
|
+
);
|
|
20
|
+
}}
|
|
21
|
+
</For>
|
|
22
|
+
<For each={props.blockChildren}>
|
|
23
|
+
{(child, _index) => {
|
|
24
|
+
const index = _index();
|
|
25
|
+
return (
|
|
26
|
+
<BlockStyles
|
|
27
|
+
key={"block-style-" + child.id}
|
|
28
|
+
block={child}
|
|
29
|
+
></BlockStyles>
|
|
30
|
+
);
|
|
31
|
+
}}
|
|
32
|
+
</For>
|
|
33
|
+
</Dynamic>
|
|
34
|
+
</Show>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default RenderComponent;
|
|
@@ -2,6 +2,7 @@ import { Show, For } from "solid-js";
|
|
|
2
2
|
import { createMutable } from "solid-js/store";
|
|
3
3
|
import { css } from "solid-styled-components";
|
|
4
4
|
import { isEditing } from "../functions/is-editing.js";
|
|
5
|
+
import BlockStyles from "./render-block/block-styles";
|
|
5
6
|
import RenderBlock from "./render-block/render-block";
|
|
6
7
|
|
|
7
8
|
function RenderBlocks(props) {
|
|
@@ -47,7 +48,16 @@ function RenderBlocks(props) {
|
|
|
47
48
|
{(block, _index) => {
|
|
48
49
|
const index = _index();
|
|
49
50
|
|
|
50
|
-
return <RenderBlock key={block.id} block={block}></RenderBlock>;
|
|
51
|
+
return <RenderBlock key={"render-block-" + block.id} block={block}></RenderBlock>;
|
|
52
|
+
}}
|
|
53
|
+
</For>
|
|
54
|
+
</Show>
|
|
55
|
+
<Show when={props.blocks}>
|
|
56
|
+
<For each={props.blocks}>
|
|
57
|
+
{(block, _index) => {
|
|
58
|
+
const index = _index();
|
|
59
|
+
|
|
60
|
+
return <BlockStyles key={"block-style-" + block.id} block={block}></BlockStyles>;
|
|
51
61
|
}}
|
|
52
62
|
</For>
|
|
53
63
|
</Show>
|
|
@@ -4,6 +4,7 @@ import { createMutable } from "solid-js/store";
|
|
|
4
4
|
import { css } from "solid-styled-components";
|
|
5
5
|
|
|
6
6
|
import { isEditing } from "../functions/is-editing.js";
|
|
7
|
+
import BlockStyles from "./render-block/block-styles.lite";
|
|
7
8
|
import RenderBlock from "./render-block/render-block.lite";
|
|
8
9
|
|
|
9
10
|
function RenderBlocks(props) {
|
|
@@ -64,7 +65,25 @@ function RenderBlocks(props) {
|
|
|
64
65
|
<For each={props.blocks}>
|
|
65
66
|
{(block, _index) => {
|
|
66
67
|
const index = _index();
|
|
67
|
-
return
|
|
68
|
+
return (
|
|
69
|
+
<RenderBlock
|
|
70
|
+
key={"render-block-" + block.id}
|
|
71
|
+
block={block}
|
|
72
|
+
></RenderBlock>
|
|
73
|
+
);
|
|
74
|
+
}}
|
|
75
|
+
</For>
|
|
76
|
+
</Show>
|
|
77
|
+
<Show when={props.blocks}>
|
|
78
|
+
<For each={props.blocks}>
|
|
79
|
+
{(block, _index) => {
|
|
80
|
+
const index = _index();
|
|
81
|
+
return (
|
|
82
|
+
<BlockStyles
|
|
83
|
+
key={"block-style-" + block.id}
|
|
84
|
+
block={block}
|
|
85
|
+
></BlockStyles>
|
|
86
|
+
);
|
|
68
87
|
}}
|
|
69
88
|
</For>
|
|
70
89
|
</Show>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Show, onMount } from "solid-js";
|
|
2
2
|
import { Dynamic } from "solid-js/web";
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
4
5
|
import { TARGET } from "../../constants/target.js";
|
|
5
6
|
import BuilderContext from "../../context/builder.context";
|
|
6
7
|
import { evaluate } from "../../functions/evaluate.js";
|
|
@@ -11,6 +12,7 @@ import { isBrowser } from "../../functions/is-browser.js";
|
|
|
11
12
|
import { isEditing } from "../../functions/is-editing.js";
|
|
12
13
|
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
13
14
|
import { previewingModelName } from "../../functions/previewing-model-name.js";
|
|
15
|
+
import { components, createRegisterComponentMessage } from "../../functions/register-component.js";
|
|
14
16
|
import { track } from "../../functions/track.js";
|
|
15
17
|
import RenderBlocks from "../render-blocks";
|
|
16
18
|
import RenderContentStyles from "./components/render-styles";
|
|
@@ -43,6 +45,19 @@ function RenderContent(props) {
|
|
|
43
45
|
return {};
|
|
44
46
|
},
|
|
45
47
|
|
|
48
|
+
get allRegisteredComponents() {
|
|
49
|
+
const allComponentsArray = [...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
|
|
50
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
51
|
+
// existing usage.
|
|
52
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
53
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
54
|
+
...components, ...(props.customComponents || [])];
|
|
55
|
+
const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,
|
|
56
|
+
[curr.name]: curr
|
|
57
|
+
}), {});
|
|
58
|
+
return allComponents;
|
|
59
|
+
},
|
|
60
|
+
|
|
46
61
|
processMessage(event) {
|
|
47
62
|
const {
|
|
48
63
|
data
|
|
@@ -128,20 +143,26 @@ function RenderContent(props) {
|
|
|
128
143
|
},
|
|
129
144
|
|
|
130
145
|
emitStateUpdate() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
if (isEditing()) {
|
|
147
|
+
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
148
|
+
detail: {
|
|
149
|
+
state: state.contentState,
|
|
150
|
+
ref: {
|
|
151
|
+
name: props.model
|
|
152
|
+
}
|
|
136
153
|
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
139
156
|
}
|
|
140
157
|
|
|
141
158
|
});
|
|
142
159
|
onMount(() => {
|
|
143
160
|
if (isBrowser()) {
|
|
144
161
|
if (isEditing()) {
|
|
162
|
+
Object.values(state.allRegisteredComponents).forEach(registeredComponent => {
|
|
163
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
164
|
+
window.parent?.postMessage(message, "*");
|
|
165
|
+
});
|
|
145
166
|
window.addEventListener("message", state.processMessage);
|
|
146
167
|
window.addEventListener("builder:component:stateChangeListenerActivated", state.emitStateUpdate);
|
|
147
168
|
}
|
|
@@ -192,6 +213,10 @@ function RenderContent(props) {
|
|
|
192
213
|
|
|
193
214
|
get apiKey() {
|
|
194
215
|
return props.apiKey;
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
get registeredComponents() {
|
|
219
|
+
return state.allRegisteredComponents;
|
|
195
220
|
}
|
|
196
221
|
|
|
197
222
|
}} component={BuilderContext.Provider}>
|
|
@@ -2,6 +2,7 @@ import { useContext, Show, onMount } from "solid-js";
|
|
|
2
2
|
import { Dynamic } from "solid-js/web";
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
4
|
|
|
5
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
6
|
import { TARGET } from "../../constants/target.js";
|
|
6
7
|
import BuilderContext from "../../context/builder.context";
|
|
7
8
|
import { evaluate } from "../../functions/evaluate.js";
|
|
@@ -15,6 +16,10 @@ import { isBrowser } from "../../functions/is-browser.js";
|
|
|
15
16
|
import { isEditing } from "../../functions/is-editing.js";
|
|
16
17
|
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
17
18
|
import { previewingModelName } from "../../functions/previewing-model-name.js";
|
|
19
|
+
import {
|
|
20
|
+
components,
|
|
21
|
+
createRegisterComponentMessage,
|
|
22
|
+
} from "../../functions/register-component.js";
|
|
18
23
|
import { track } from "../../functions/track.js";
|
|
19
24
|
import RenderBlocks from "../render-blocks.lite";
|
|
20
25
|
import RenderContentStyles from "./components/render-styles.lite";
|
|
@@ -44,9 +49,23 @@ function RenderContent(props) {
|
|
|
44
49
|
};
|
|
45
50
|
},
|
|
46
51
|
get context() {
|
|
47
|
-
return {} as
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
return {} as Dictionary<any>;
|
|
53
|
+
},
|
|
54
|
+
get allRegisteredComponents() {
|
|
55
|
+
const allComponentsArray = [
|
|
56
|
+
...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
|
|
57
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
58
|
+
// existing usage.
|
|
59
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
60
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
61
|
+
...components,
|
|
62
|
+
...(props.customComponents || []),
|
|
63
|
+
];
|
|
64
|
+
const allComponents = allComponentsArray.reduce(
|
|
65
|
+
(acc, curr) => ({ ...acc, [curr.name]: curr }),
|
|
66
|
+
{} as RegisteredComponents
|
|
67
|
+
);
|
|
68
|
+
return allComponents;
|
|
50
69
|
},
|
|
51
70
|
processMessage(event: MessageEvent) {
|
|
52
71
|
const { data } = event;
|
|
@@ -124,25 +143,33 @@ function RenderContent(props) {
|
|
|
124
143
|
});
|
|
125
144
|
},
|
|
126
145
|
emitStateUpdate() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
146
|
+
if (isEditing()) {
|
|
147
|
+
window.dispatchEvent(
|
|
148
|
+
new CustomEvent<BuilderComponentStateChange>(
|
|
149
|
+
"builder:component:stateChange",
|
|
150
|
+
{
|
|
151
|
+
detail: {
|
|
152
|
+
state: state.contentState,
|
|
153
|
+
ref: {
|
|
154
|
+
name: props.model,
|
|
155
|
+
},
|
|
135
156
|
},
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
)
|
|
139
|
-
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
140
161
|
},
|
|
141
162
|
});
|
|
142
163
|
|
|
143
164
|
onMount(() => {
|
|
144
165
|
if (isBrowser()) {
|
|
145
166
|
if (isEditing()) {
|
|
167
|
+
Object.values(state.allRegisteredComponents).forEach(
|
|
168
|
+
(registeredComponent) => {
|
|
169
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
170
|
+
window.parent?.postMessage(message, "*");
|
|
171
|
+
}
|
|
172
|
+
);
|
|
146
173
|
window.addEventListener("message", state.processMessage);
|
|
147
174
|
window.addEventListener(
|
|
148
175
|
"builder:component:stateChangeListenerActivated",
|
|
@@ -198,6 +225,9 @@ function RenderContent(props) {
|
|
|
198
225
|
get apiKey() {
|
|
199
226
|
return props.apiKey;
|
|
200
227
|
},
|
|
228
|
+
get registeredComponents() {
|
|
229
|
+
return state.allRegisteredComponents;
|
|
230
|
+
},
|
|
201
231
|
}}
|
|
202
232
|
component={BuilderContext.Provider}
|
|
203
233
|
>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Show } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
2
3
|
import { createMutable } from "solid-js/store";
|
|
3
4
|
import { TARGET } from "../constants/target.js";
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ function RenderInlinedStyles(props) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
});
|
|
18
|
-
return <Show when={TARGET === "svelte"}>
|
|
19
|
+
return <Show fallback={<Dynamic component={state.tagName}>{props.styles}</Dynamic>} when={TARGET === "svelte"}>
|
|
19
20
|
<div innerHTML={state.injectedStyleScript}></div>
|
|
20
21
|
</Show>;
|
|
21
22
|
}
|
|
@@ -17,7 +17,10 @@ function RenderInlinedStyles(props) {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<Show
|
|
20
|
+
<Show
|
|
21
|
+
fallback={<Dynamic component={state.tagName}>{props.styles}</Dynamic>}
|
|
22
|
+
when={TARGET === "svelte"}
|
|
23
|
+
>
|
|
21
24
|
<div innerHTML={state.injectedStyleScript}></div>
|
|
22
25
|
</Show>
|
|
23
26
|
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { default as Button } from "../blocks/button/button.jsx";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
|
|
19
|
+
import { default as Columns } from "../blocks/columns/columns.jsx";
|
|
20
|
+
import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info";
|
|
21
|
+
import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info";
|
|
22
|
+
import { default as Fragment } from "../blocks/fragment/fragment.jsx";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
|
|
24
|
+
import { default as Image } from "../blocks/image/image.jsx";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
|
|
26
|
+
import { default as Section } from "../blocks/section/section.jsx";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
|
|
28
|
+
import { default as Symbol } from "../blocks/symbol/symbol.jsx";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
|
|
30
|
+
import { default as Text } from "../blocks/text/text.jsx";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
|
|
32
|
+
import { default as Video } from "../blocks/video/video.jsx";
|
|
33
|
+
const getDefaultRegisteredComponents = () => [
|
|
34
|
+
__spreadValues({ component: Columns }, columnsComponentInfo),
|
|
35
|
+
__spreadValues({ component: Image }, imageComponentInfo),
|
|
36
|
+
__spreadValues({ component: Text }, textComponentInfo),
|
|
37
|
+
__spreadValues({ component: Video }, videoComponentInfo),
|
|
38
|
+
__spreadValues({ component: Symbol }, symbolComponentInfo),
|
|
39
|
+
__spreadValues({ component: Button }, buttonComponentInfo),
|
|
40
|
+
__spreadValues({ component: Section }, sectionComponentInfo),
|
|
41
|
+
__spreadValues({ component: Fragment }, fragmentComponentInfo)
|
|
42
|
+
];
|
|
43
|
+
export {
|
|
44
|
+
getDefaultRegisteredComponents
|
|
45
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,9 +16,12 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
function getBlockComponentOptions(block) {
|
|
18
21
|
var _a;
|
|
19
|
-
return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options)
|
|
22
|
+
return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
23
|
+
builderBlock: block
|
|
24
|
+
});
|
|
20
25
|
}
|
|
21
26
|
export {
|
|
22
27
|
getBlockComponentOptions
|
|
@@ -30,10 +30,10 @@ function getBlockStyles(block) {
|
|
|
30
30
|
var _a, _b, _c, _d, _e;
|
|
31
31
|
const styles = __spreadValues({}, convertStyleObject((_a = block.responsiveStyles) == null ? void 0 : _a.large));
|
|
32
32
|
if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
|
|
33
|
-
styles[`@media (max-width: ${sizes.medium})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
|
|
33
|
+
styles[`@media (max-width: ${sizes.medium.max})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
|
|
34
34
|
}
|
|
35
35
|
if ((_d = block.responsiveStyles) == null ? void 0 : _d.small) {
|
|
36
|
-
styles[`@media (max-width: ${sizes.small})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
|
|
36
|
+
styles[`@media (max-width: ${sizes.small.max})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
|
|
37
37
|
}
|
|
38
38
|
return styles;
|
|
39
39
|
}
|