@builder.io/sdk-solid 0.0.8-4 → 0.0.8-5
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 +4 -1
- package/entry-point/index.jsx +0 -5
- package/src/blocks/button/button.jsx +0 -13
- package/src/blocks/button/button.lite.tsx +0 -23
- package/src/blocks/button/component-info.js +0 -41
- package/src/blocks/columns/columns.jsx +0 -91
- package/src/blocks/columns/columns.lite.tsx +0 -102
- package/src/blocks/columns/component-info.js +0 -217
- package/src/blocks/custom-code/component-info.js +0 -31
- package/src/blocks/custom-code/custom-code.jsx +0 -52
- package/src/blocks/custom-code/custom-code.lite.tsx +0 -69
- package/src/blocks/embed/component-info.js +0 -24
- package/src/blocks/embed/embed.jsx +0 -52
- package/src/blocks/embed/embed.lite.tsx +0 -61
- package/src/blocks/form/component-info.js +0 -262
- package/src/blocks/form/form.jsx +0 -253
- package/src/blocks/form/form.lite.tsx +0 -293
- package/src/blocks/fragment/component-info.js +0 -11
- package/src/blocks/fragment/fragment.jsx +0 -5
- package/src/blocks/fragment/fragment.lite.tsx +0 -5
- package/src/blocks/image/component-info.js +0 -104
- package/src/blocks/image/image.jsx +0 -54
- package/src/blocks/image/image.lite.tsx +0 -83
- package/src/blocks/img/component-info.js +0 -20
- package/src/blocks/img/img.jsx +0 -10
- package/src/blocks/img/img.lite.tsx +0 -18
- package/src/blocks/input/component-info.js +0 -74
- package/src/blocks/input/input.jsx +0 -7
- package/src/blocks/input/input.lite.tsx +0 -20
- package/src/blocks/raw-text/component-info.js +0 -16
- package/src/blocks/raw-text/raw-text.jsx +0 -5
- package/src/blocks/raw-text/raw-text.lite.tsx +0 -10
- package/src/blocks/section/component-info.js +0 -49
- package/src/blocks/section/section.jsx +0 -9
- package/src/blocks/section/section.lite.tsx +0 -18
- package/src/blocks/select/component-info.js +0 -59
- package/src/blocks/select/select.jsx +0 -16
- package/src/blocks/select/select.lite.tsx +0 -28
- package/src/blocks/submit-button/component-info.js +0 -28
- package/src/blocks/submit-button/submit-button.jsx +0 -7
- package/src/blocks/submit-button/submit-button.lite.tsx +0 -9
- package/src/blocks/symbol/component-info.js +0 -42
- package/src/blocks/symbol/symbol.jsx +0 -25
- package/src/blocks/symbol/symbol.lite.tsx +0 -41
- package/src/blocks/text/component-info.js +0 -24
- package/src/blocks/text/text.jsx +0 -5
- package/src/blocks/text/text.lite.tsx +0 -5
- package/src/blocks/textarea/component-info.js +0 -47
- package/src/blocks/textarea/textarea.jsx +0 -5
- package/src/blocks/textarea/textarea.lite.tsx +0 -13
- package/src/blocks/video/component-info.js +0 -106
- package/src/blocks/video/video.jsx +0 -14
- package/src/blocks/video/video.lite.tsx +0 -26
- package/src/components/error-boundary.jsx +0 -5
- package/src/components/error-boundary.lite.tsx +0 -5
- package/src/components/render-block/block-styles.jsx +0 -36
- package/src/components/render-block/block-styles.lite.tsx +0 -38
- package/src/components/render-block/render-block.jsx +0 -125
- package/src/components/render-block/render-block.lite.tsx +0 -137
- package/src/components/render-blocks.jsx +0 -57
- package/src/components/render-blocks.lite.tsx +0 -75
- package/src/components/render-content/components/render-styles.jsx +0 -74
- package/src/components/render-content/components/render-styles.lite.tsx +0 -76
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/render-content.jsx +0 -234
- package/src/components/render-content/render-content.lite.tsx +0 -260
- package/src/components/render-inlined-styles.jsx +0 -24
- package/src/components/render-inlined-styles.lite.tsx +0 -29
- package/src/constants/builder-registered-components.js +0 -29
- package/src/constants/device-sizes.js +0 -39
- package/src/constants/target.js +0 -4
- package/src/context/builder.context.js +0 -11
- package/src/functions/evaluate.js +0 -28
- package/src/functions/event-handler-name.js +0 -7
- package/src/functions/fast-clone.js +0 -4
- package/src/functions/get-block-actions.js +0 -23
- package/src/functions/get-block-component-options.js +0 -23
- package/src/functions/get-block-properties.js +0 -29
- package/src/functions/get-block-styles.js +0 -42
- package/src/functions/get-block-tag.js +0 -6
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-builder-search-params/index.js +0 -22
- package/src/functions/get-content/fn.test.js +0 -31
- package/src/functions/get-content/index.js +0 -138
- package/src/functions/get-fetch.js +0 -34
- package/src/functions/get-global-this.js +0 -18
- package/src/functions/get-processed-block.js +0 -46
- package/src/functions/get-processed-block.test.js +0 -31
- package/src/functions/if-target.js +0 -15
- package/src/functions/is-browser.js +0 -6
- package/src/functions/is-editing.js +0 -7
- package/src/functions/is-iframe.js +0 -7
- package/src/functions/is-previewing.js +0 -14
- package/src/functions/macro-eval.js +0 -5
- package/src/functions/on-change.js +0 -27
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/previewing-model-name.js +0 -11
- package/src/functions/register-component.js +0 -53
- package/src/functions/register.js +0 -29
- package/src/functions/set-editor-settings.js +0 -15
- package/src/functions/set.js +0 -11
- package/src/functions/set.test.js +0 -16
- package/src/functions/track.js +0 -22
- package/src/functions/transform-block.js +0 -6
- package/src/index-helpers/blocks-exports.js +0 -20
- package/src/index-helpers/top-of-file.js +0 -4
- package/src/index.js +0 -10
- package/src/scripts/init-editing.js +0 -80
- package/src/types/builder-block.js +0 -0
- package/src/types/builder-content.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -0
- package/src/types/typescript.js +0 -0
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
import RenderInlinedStyles from "../render-inlined-styles";
|
|
3
|
-
|
|
4
|
-
function BlockStyles(props) {
|
|
5
|
-
const state = createMutable({
|
|
6
|
-
camelToKebabCase(string) {
|
|
7
|
-
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
get css() {
|
|
11
|
-
// TODO: media queries
|
|
12
|
-
const styleObject = props.block.responsiveStyles?.large;
|
|
13
|
-
|
|
14
|
-
if (!styleObject) {
|
|
15
|
-
return "";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let str = `.${props.block.id} {`;
|
|
19
|
-
|
|
20
|
-
for (const key in styleObject) {
|
|
21
|
-
const value = styleObject[key];
|
|
22
|
-
|
|
23
|
-
if (typeof value === "string") {
|
|
24
|
-
str += `${state.camelToKebabCase(key)}: ${value};`;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
str += "}";
|
|
29
|
-
return str;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
return <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default BlockStyles;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
|
|
3
|
-
import RenderInlinedStyles from "../render-inlined-styles.lite";
|
|
4
|
-
|
|
5
|
-
function BlockStyles(props) {
|
|
6
|
-
const state = createMutable({
|
|
7
|
-
camelToKebabCase(string: string) {
|
|
8
|
-
return string
|
|
9
|
-
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
|
|
10
|
-
.toLowerCase();
|
|
11
|
-
},
|
|
12
|
-
get css() {
|
|
13
|
-
// TODO: media queries
|
|
14
|
-
const styleObject = props.block.responsiveStyles?.large;
|
|
15
|
-
|
|
16
|
-
if (!styleObject) {
|
|
17
|
-
return "";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let str = `.${props.block.id} {`;
|
|
21
|
-
|
|
22
|
-
for (const key in styleObject) {
|
|
23
|
-
const value = styleObject[key];
|
|
24
|
-
|
|
25
|
-
if (typeof value === "string") {
|
|
26
|
-
str += `${state.camelToKebabCase(key)}: ${value};`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
str += "}";
|
|
31
|
-
return str;
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default BlockStyles;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useContext, Show, For } from "solid-js";
|
|
2
|
-
import { Dynamic } from "solid-js/web";
|
|
3
|
-
import { createMutable } from "solid-js/store";
|
|
4
|
-
import { TARGET } from "../../constants/target.js";
|
|
5
|
-
import BuilderContext from "../../context/builder.context";
|
|
6
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
7
|
-
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
8
|
-
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
9
|
-
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
10
|
-
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
11
|
-
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
12
|
-
import BlockStyles from "./block-styles";
|
|
13
|
-
|
|
14
|
-
function RenderBlock(props) {
|
|
15
|
-
const state = createMutable({
|
|
16
|
-
get component() {
|
|
17
|
-
const componentName = state.useBlock.component?.name;
|
|
18
|
-
|
|
19
|
-
if (!componentName) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const ref = builderContext.registeredComponents[componentName];
|
|
24
|
-
|
|
25
|
-
if (!ref) {
|
|
26
|
-
// TODO: Public doc page with more info about this message
|
|
27
|
-
console.warn(`
|
|
28
|
-
Could not find a registered component named "${componentName}".
|
|
29
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
30
|
-
return undefined;
|
|
31
|
-
} else {
|
|
32
|
-
return ref;
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
get componentInfo() {
|
|
37
|
-
return state.component?.info;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
get componentRef() {
|
|
41
|
-
return state.component?.component;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
get tagName() {
|
|
45
|
-
return getBlockTag(state.useBlock);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
get useBlock() {
|
|
49
|
-
return getProcessedBlock({
|
|
50
|
-
block: props.block,
|
|
51
|
-
state: builderContext.state,
|
|
52
|
-
context: builderContext.context
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
get propertiesAndActions() {
|
|
57
|
-
return { ...getBlockProperties(state.useBlock),
|
|
58
|
-
...getBlockActions({
|
|
59
|
-
block: state.useBlock,
|
|
60
|
-
state: builderContext.state,
|
|
61
|
-
context: builderContext.context
|
|
62
|
-
})
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
get css() {
|
|
67
|
-
return getBlockStyles(state.useBlock);
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
get componentOptions() {
|
|
71
|
-
return getBlockComponentOptions(state.useBlock);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
get children() {
|
|
75
|
-
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
76
|
-
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
77
|
-
// but still receive and need to render children.
|
|
78
|
-
// return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
|
|
79
|
-
return state.useBlock.children ?? [];
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
get noCompRefChildren() {
|
|
83
|
-
return state.componentRef ? [] : state.children;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
const builderContext = useContext(BuilderContext);
|
|
88
|
-
return <>
|
|
89
|
-
<Show fallback={<Dynamic {...state.componentOptions} attributes={state.propertiesAndActions} builderBlock={state.useBlock} style={state.css} component={state.componentRef}>
|
|
90
|
-
<For each={state.children}>
|
|
91
|
-
{(child, _index) => {
|
|
92
|
-
const index = _index();
|
|
93
|
-
|
|
94
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
95
|
-
}}
|
|
96
|
-
</For>
|
|
97
|
-
</Dynamic>} when={!state.componentInfo?.noWrap}>
|
|
98
|
-
<Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}>
|
|
99
|
-
<Show when={TARGET === "vue" || TARGET === "svelte"}>
|
|
100
|
-
<BlockStyles block={state.useBlock}></BlockStyles>
|
|
101
|
-
</Show>
|
|
102
|
-
<Show when={state.componentRef}>
|
|
103
|
-
<Dynamic {...state.componentOptions} builderBlock={state.useBlock} component={state.componentRef}>
|
|
104
|
-
<For each={state.children}>
|
|
105
|
-
{(child, _index) => {
|
|
106
|
-
const index = _index();
|
|
107
|
-
|
|
108
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
109
|
-
}}
|
|
110
|
-
</For>
|
|
111
|
-
</Dynamic>
|
|
112
|
-
</Show>
|
|
113
|
-
<For each={state.noCompRefChildren}>
|
|
114
|
-
{(child, _index) => {
|
|
115
|
-
const index = _index();
|
|
116
|
-
|
|
117
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
118
|
-
}}
|
|
119
|
-
</For>
|
|
120
|
-
</Dynamic>
|
|
121
|
-
</Show>
|
|
122
|
-
</>;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export default RenderBlock;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { useContext, Show, For } from "solid-js";
|
|
2
|
-
import { Dynamic } from "solid-js/web";
|
|
3
|
-
import { createMutable } from "solid-js/store";
|
|
4
|
-
|
|
5
|
-
import { TARGET } from "../../constants/target.js";
|
|
6
|
-
import BuilderContext from "../../context/builder.context";
|
|
7
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
8
|
-
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
9
|
-
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
10
|
-
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
11
|
-
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
12
|
-
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
13
|
-
import BlockStyles from "./block-styles.lite";
|
|
14
|
-
|
|
15
|
-
function RenderBlock(props) {
|
|
16
|
-
const state = createMutable({
|
|
17
|
-
get component() {
|
|
18
|
-
const componentName = state.useBlock.component?.name;
|
|
19
|
-
|
|
20
|
-
if (!componentName) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const ref = builderContext.registeredComponents[componentName];
|
|
25
|
-
|
|
26
|
-
if (!ref) {
|
|
27
|
-
// TODO: Public doc page with more info about this message
|
|
28
|
-
console.warn(`
|
|
29
|
-
Could not find a registered component named "${componentName}".
|
|
30
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
31
|
-
return undefined;
|
|
32
|
-
} else {
|
|
33
|
-
return ref;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
get componentInfo() {
|
|
37
|
-
return state.component?.info;
|
|
38
|
-
},
|
|
39
|
-
get componentRef() {
|
|
40
|
-
return state.component?.component;
|
|
41
|
-
},
|
|
42
|
-
get tagName() {
|
|
43
|
-
return getBlockTag(state.useBlock);
|
|
44
|
-
},
|
|
45
|
-
get useBlock() {
|
|
46
|
-
return getProcessedBlock({
|
|
47
|
-
block: props.block,
|
|
48
|
-
state: builderContext.state,
|
|
49
|
-
context: builderContext.context,
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
get propertiesAndActions() {
|
|
53
|
-
return {
|
|
54
|
-
...getBlockProperties(state.useBlock),
|
|
55
|
-
...getBlockActions({
|
|
56
|
-
block: state.useBlock,
|
|
57
|
-
state: builderContext.state,
|
|
58
|
-
context: builderContext.context,
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
get css() {
|
|
63
|
-
return getBlockStyles(state.useBlock);
|
|
64
|
-
},
|
|
65
|
-
get componentOptions() {
|
|
66
|
-
return getBlockComponentOptions(state.useBlock);
|
|
67
|
-
},
|
|
68
|
-
get children() {
|
|
69
|
-
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
70
|
-
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
71
|
-
// but still receive and need to render children.
|
|
72
|
-
// return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
|
|
73
|
-
return state.useBlock.children ?? [];
|
|
74
|
-
},
|
|
75
|
-
get noCompRefChildren() {
|
|
76
|
-
return state.componentRef ? [] : state.children;
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const builderContext = useContext(BuilderContext);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<>
|
|
84
|
-
<Show
|
|
85
|
-
fallback={
|
|
86
|
-
<Dynamic
|
|
87
|
-
{...state.componentOptions}
|
|
88
|
-
attributes={state.propertiesAndActions}
|
|
89
|
-
builderBlock={state.useBlock}
|
|
90
|
-
style={state.css}
|
|
91
|
-
component={state.componentRef}
|
|
92
|
-
>
|
|
93
|
-
<For each={state.children}>
|
|
94
|
-
{(child, _index) => {
|
|
95
|
-
const index = _index();
|
|
96
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
97
|
-
}}
|
|
98
|
-
</For>
|
|
99
|
-
</Dynamic>
|
|
100
|
-
}
|
|
101
|
-
when={!state.componentInfo?.noWrap}
|
|
102
|
-
>
|
|
103
|
-
<Dynamic
|
|
104
|
-
{...state.propertiesAndActions}
|
|
105
|
-
style={state.css}
|
|
106
|
-
component={state.tagName}
|
|
107
|
-
>
|
|
108
|
-
<Show when={TARGET === "vue" || TARGET === "svelte"}>
|
|
109
|
-
<BlockStyles block={state.useBlock}></BlockStyles>
|
|
110
|
-
</Show>
|
|
111
|
-
<Show when={state.componentRef}>
|
|
112
|
-
<Dynamic
|
|
113
|
-
{...state.componentOptions}
|
|
114
|
-
builderBlock={state.useBlock}
|
|
115
|
-
component={state.componentRef}
|
|
116
|
-
>
|
|
117
|
-
<For each={state.children}>
|
|
118
|
-
{(child, _index) => {
|
|
119
|
-
const index = _index();
|
|
120
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
121
|
-
}}
|
|
122
|
-
</For>
|
|
123
|
-
</Dynamic>
|
|
124
|
-
</Show>
|
|
125
|
-
<For each={state.noCompRefChildren}>
|
|
126
|
-
{(child, _index) => {
|
|
127
|
-
const index = _index();
|
|
128
|
-
return <RenderBlock block={child}></RenderBlock>;
|
|
129
|
-
}}
|
|
130
|
-
</For>
|
|
131
|
-
</Dynamic>
|
|
132
|
-
</Show>
|
|
133
|
-
</>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export default RenderBlock;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Show, For } from "solid-js";
|
|
2
|
-
import { createMutable } from "solid-js/store";
|
|
3
|
-
import { css } from "solid-styled-components";
|
|
4
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
5
|
-
import RenderBlock from "./render-block/render-block";
|
|
6
|
-
|
|
7
|
-
function RenderBlocks(props) {
|
|
8
|
-
const state = createMutable({
|
|
9
|
-
get className() {
|
|
10
|
-
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
onClick() {
|
|
14
|
-
if (isEditing() && !props.blocks?.length) {
|
|
15
|
-
window.parent?.postMessage({
|
|
16
|
-
type: "builder.clickEmptyBlocks",
|
|
17
|
-
data: {
|
|
18
|
-
parentElementId: props.parent,
|
|
19
|
-
dataPath: props.path
|
|
20
|
-
}
|
|
21
|
-
}, "*");
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
onMouseEnter() {
|
|
26
|
-
if (isEditing() && !props.blocks?.length) {
|
|
27
|
-
window.parent?.postMessage({
|
|
28
|
-
type: "builder.hoverEmptyBlocks",
|
|
29
|
-
data: {
|
|
30
|
-
parentElementId: props.parent,
|
|
31
|
-
dataPath: props.path
|
|
32
|
-
}
|
|
33
|
-
}, "*");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
return <div class={state.className + " " + css({
|
|
39
|
-
display: "flex",
|
|
40
|
-
flexDirection: "column",
|
|
41
|
-
alignItems: "stretch"
|
|
42
|
-
})} builder-path={props.path} builder-parent-id={props.parent} dataSet={{
|
|
43
|
-
class: state.className
|
|
44
|
-
}} onClick={event => state.onClick()} onMouseEnter={event => state.onMouseEnter()}>
|
|
45
|
-
<Show when={props.blocks}>
|
|
46
|
-
<For each={props.blocks}>
|
|
47
|
-
{(block, _index) => {
|
|
48
|
-
const index = _index();
|
|
49
|
-
|
|
50
|
-
return <RenderBlock key={block.id} block={block}></RenderBlock>;
|
|
51
|
-
}}
|
|
52
|
-
</For>
|
|
53
|
-
</Show>
|
|
54
|
-
</div>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default RenderBlocks;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Show, For } from "solid-js";
|
|
2
|
-
|
|
3
|
-
import { createMutable } from "solid-js/store";
|
|
4
|
-
import { css } from "solid-styled-components";
|
|
5
|
-
|
|
6
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
7
|
-
import RenderBlock from "./render-block/render-block.lite";
|
|
8
|
-
|
|
9
|
-
function RenderBlocks(props) {
|
|
10
|
-
const state = createMutable({
|
|
11
|
-
get className() {
|
|
12
|
-
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
13
|
-
},
|
|
14
|
-
onClick() {
|
|
15
|
-
if (isEditing() && !props.blocks?.length) {
|
|
16
|
-
window.parent?.postMessage(
|
|
17
|
-
{
|
|
18
|
-
type: "builder.clickEmptyBlocks",
|
|
19
|
-
data: {
|
|
20
|
-
parentElementId: props.parent,
|
|
21
|
-
dataPath: props.path,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
"*"
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
onMouseEnter() {
|
|
29
|
-
if (isEditing() && !props.blocks?.length) {
|
|
30
|
-
window.parent?.postMessage(
|
|
31
|
-
{
|
|
32
|
-
type: "builder.hoverEmptyBlocks",
|
|
33
|
-
data: {
|
|
34
|
-
parentElementId: props.parent,
|
|
35
|
-
dataPath: props.path,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
"*"
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div
|
|
46
|
-
class={
|
|
47
|
-
state.className +
|
|
48
|
-
" " +
|
|
49
|
-
css({
|
|
50
|
-
display: "flex",
|
|
51
|
-
flexDirection: "column",
|
|
52
|
-
alignItems: "stretch",
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
builder-path={props.path}
|
|
56
|
-
builder-parent-id={props.parent}
|
|
57
|
-
dataSet={{
|
|
58
|
-
class: state.className,
|
|
59
|
-
}}
|
|
60
|
-
onClick={(event) => state.onClick()}
|
|
61
|
-
onMouseEnter={(event) => state.onMouseEnter()}
|
|
62
|
-
>
|
|
63
|
-
<Show when={props.blocks}>
|
|
64
|
-
<For each={props.blocks}>
|
|
65
|
-
{(block, _index) => {
|
|
66
|
-
const index = _index();
|
|
67
|
-
return <RenderBlock key={block.id} block={block}></RenderBlock>;
|
|
68
|
-
}}
|
|
69
|
-
</For>
|
|
70
|
-
</Show>
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default RenderBlocks;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
import RenderInlinedStyles from "../../render-inlined-styles";
|
|
3
|
-
|
|
4
|
-
function RenderContentStyles(props) {
|
|
5
|
-
const state = createMutable({
|
|
6
|
-
getCssFromFont(font) {
|
|
7
|
-
// TODO: compute what font sizes are used and only load those.......
|
|
8
|
-
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
9
|
-
const name = family.split(",")[0];
|
|
10
|
-
const url = font.fileUrl ?? font?.files?.regular;
|
|
11
|
-
let str = "";
|
|
12
|
-
|
|
13
|
-
if (url && family && name) {
|
|
14
|
-
str += `
|
|
15
|
-
@font-face {
|
|
16
|
-
font-family: "${family}";
|
|
17
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
18
|
-
font-display: fallback;
|
|
19
|
-
font-weight: 400;
|
|
20
|
-
}
|
|
21
|
-
`.trim();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (font.files) {
|
|
25
|
-
for (const weight in font.files) {
|
|
26
|
-
const isNumber = String(Number(weight)) === weight;
|
|
27
|
-
|
|
28
|
-
if (!isNumber) {
|
|
29
|
-
continue;
|
|
30
|
-
} // TODO: maybe limit number loaded
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const weightUrl = font.files[weight];
|
|
34
|
-
|
|
35
|
-
if (weightUrl && weightUrl !== url) {
|
|
36
|
-
str += `
|
|
37
|
-
@font-face {
|
|
38
|
-
font-family: "${family}";
|
|
39
|
-
src: url('${weightUrl}') format('woff2');
|
|
40
|
-
font-display: fallback;
|
|
41
|
-
font-weight: ${weight};
|
|
42
|
-
}
|
|
43
|
-
`.trim();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return str;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
getFontCss({
|
|
52
|
-
customFonts
|
|
53
|
-
}) {
|
|
54
|
-
// TODO: flag for this
|
|
55
|
-
// if (!this.builder.allowCustomFonts) {
|
|
56
|
-
// return '';
|
|
57
|
-
// }
|
|
58
|
-
// TODO: separate internal data from external
|
|
59
|
-
return customFonts?.map(font => this.getCssFromFont(font))?.join(" ") || "";
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
get injectedStyles() {
|
|
63
|
-
return `
|
|
64
|
-
${props.cssCode || ""}
|
|
65
|
-
${state.getFontCss({
|
|
66
|
-
customFonts: props.customFonts
|
|
67
|
-
})}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
return <RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export default RenderContentStyles;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { createMutable } from "solid-js/store";
|
|
2
|
-
|
|
3
|
-
import RenderInlinedStyles from "../../render-inlined-styles.lite";
|
|
4
|
-
|
|
5
|
-
function RenderContentStyles(props) {
|
|
6
|
-
const state = createMutable({
|
|
7
|
-
getCssFromFont(font: CustomFont) {
|
|
8
|
-
// TODO: compute what font sizes are used and only load those.......
|
|
9
|
-
const family =
|
|
10
|
-
font.family +
|
|
11
|
-
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
12
|
-
const name = family.split(",")[0];
|
|
13
|
-
const url = font.fileUrl ?? font?.files?.regular;
|
|
14
|
-
let str = "";
|
|
15
|
-
|
|
16
|
-
if (url && family && name) {
|
|
17
|
-
str += `
|
|
18
|
-
@font-face {
|
|
19
|
-
font-family: "${family}";
|
|
20
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
21
|
-
font-display: fallback;
|
|
22
|
-
font-weight: 400;
|
|
23
|
-
}
|
|
24
|
-
`.trim();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (font.files) {
|
|
28
|
-
for (const weight in font.files) {
|
|
29
|
-
const isNumber = String(Number(weight)) === weight;
|
|
30
|
-
|
|
31
|
-
if (!isNumber) {
|
|
32
|
-
continue;
|
|
33
|
-
} // TODO: maybe limit number loaded
|
|
34
|
-
|
|
35
|
-
const weightUrl = font.files[weight];
|
|
36
|
-
|
|
37
|
-
if (weightUrl && weightUrl !== url) {
|
|
38
|
-
str += `
|
|
39
|
-
@font-face {
|
|
40
|
-
font-family: "${family}";
|
|
41
|
-
src: url('${weightUrl}') format('woff2');
|
|
42
|
-
font-display: fallback;
|
|
43
|
-
font-weight: ${weight};
|
|
44
|
-
}
|
|
45
|
-
`.trim();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return str;
|
|
51
|
-
},
|
|
52
|
-
getFontCss({ customFonts }: { customFonts?: CustomFont[] }) {
|
|
53
|
-
// TODO: flag for this
|
|
54
|
-
// if (!this.builder.allowCustomFonts) {
|
|
55
|
-
// return '';
|
|
56
|
-
// }
|
|
57
|
-
// TODO: separate internal data from external
|
|
58
|
-
return (
|
|
59
|
-
customFonts?.map((font) => this.getCssFromFont(font))?.join(" ") || ""
|
|
60
|
-
);
|
|
61
|
-
},
|
|
62
|
-
get injectedStyles() {
|
|
63
|
-
return `
|
|
64
|
-
${props.cssCode || ""}
|
|
65
|
-
${state.getFontCss({
|
|
66
|
-
customFonts: props.customFonts,
|
|
67
|
-
})}`;
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default RenderContentStyles;
|