@builder.io/sdk-solid 0.0.8-23 → 0.0.8-24
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 +1 -1
- package/src/blocks/columns/columns.jsx +41 -44
- package/src/blocks/columns/component-info.js +3 -2
- package/src/blocks/custom-code/custom-code.jsx +34 -37
- package/src/blocks/embed/component-info.js +3 -2
- package/src/blocks/embed/embed.jsx +28 -31
- package/src/blocks/form/form.jsx +172 -173
- package/src/blocks/image/component-info.js +3 -2
- package/src/blocks/image/image.jsx +26 -29
- package/src/blocks/img/img.jsx +1 -1
- package/src/blocks/symbol/symbol.jsx +10 -13
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/video.jsx +19 -23
- package/src/components/render-block/block-styles.jsx +22 -27
- package/src/components/render-block/render-block.jsx +155 -159
- package/src/components/render-block/render-component.jsx +2 -2
- package/src/components/render-block/render-repeated-block.jsx +1 -1
- package/src/components/render-blocks.jsx +32 -33
- package/src/components/render-content/components/render-styles.jsx +38 -41
- package/src/components/render-content/render-content.jsx +167 -164
- package/src/components/render-inlined-styles.jsx +10 -13
- package/src/constants/builder-registered-components.js +3 -0
- package/src/functions/get-fetch.js +2 -2
- package/src/functions/get-processed-block.js +10 -6
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/scripts/init-editing.js +4 -5
package/package.json
CHANGED
|
@@ -1,56 +1,53 @@
|
|
|
1
1
|
import { For } from "solid-js";
|
|
2
|
-
import { createMutable } from "solid-js/store";
|
|
3
2
|
import { css } from "solid-styled-components";
|
|
4
3
|
import RenderBlocks from "../../components/render-blocks.jsx";
|
|
5
4
|
|
|
6
5
|
function Columns(props) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
6
|
+
function getGutterSize() {
|
|
7
|
+
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
8
|
+
}
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function getColumns() {
|
|
11
|
+
return props.columns || [];
|
|
12
|
+
}
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
function getWidth(index) {
|
|
15
|
+
const columns = getColumns();
|
|
16
|
+
return columns[index]?.width || 100 / columns.length;
|
|
17
|
+
}
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
function getColumnCssWidth(index) {
|
|
20
|
+
const columns = getColumns();
|
|
21
|
+
const gutterSize = getGutterSize();
|
|
22
|
+
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
23
|
+
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
24
|
+
}
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
function maybeApplyForTablet(prop) {
|
|
27
|
+
const _stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
return _stackColumnsAt === "tablet" ? prop : "inherit";
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
function columnsCssVars() {
|
|
33
|
+
const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
|
|
34
|
+
return {
|
|
35
|
+
"--flex-dir": flexDir,
|
|
36
|
+
"--flex-dir-tablet": maybeApplyForTablet(flexDir)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
function columnCssVars() {
|
|
41
|
+
const width = "100%";
|
|
42
|
+
const marginLeft = "0";
|
|
43
|
+
return {
|
|
44
|
+
"--column-width": width,
|
|
45
|
+
"--column-margin-left": marginLeft,
|
|
46
|
+
"--column-width-tablet": maybeApplyForTablet(width),
|
|
47
|
+
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
52
50
|
|
|
53
|
-
});
|
|
54
51
|
return <div class={"builder-columns " + css({
|
|
55
52
|
display: "flex",
|
|
56
53
|
alignItems: "stretch",
|
|
@@ -61,7 +58,7 @@ function Columns(props) {
|
|
|
61
58
|
"@media (max-width: 639px)": {
|
|
62
59
|
flexDirection: "var(--flex-dir)"
|
|
63
60
|
}
|
|
64
|
-
})} style={
|
|
61
|
+
})} style={columnsCssVars()}>
|
|
65
62
|
<For each={props.columns}>
|
|
66
63
|
{(column, _index) => {
|
|
67
64
|
const index = _index();
|
|
@@ -77,9 +74,9 @@ function Columns(props) {
|
|
|
77
74
|
marginLeft: "var(--column-margin-left) !important"
|
|
78
75
|
}
|
|
79
76
|
})} style={{
|
|
80
|
-
width:
|
|
81
|
-
"margin-left": `${index === 0 ? 0 :
|
|
82
|
-
...
|
|
77
|
+
width: getColumnCssWidth(index),
|
|
78
|
+
"margin-left": `${index === 0 ? 0 : getGutterSize()}px`,
|
|
79
|
+
...columnCssVars()
|
|
83
80
|
}} key={index}>
|
|
84
81
|
<RenderBlocks blocks={column.blocks} path={`component.options.columns.${index}.blocks`} parent={props.builderBlock.id}></RenderBlocks>
|
|
85
82
|
</div>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markSerializable } from "../util";
|
|
1
2
|
const componentInfo = {
|
|
2
3
|
name: "Columns",
|
|
3
4
|
builtIn: true,
|
|
@@ -186,7 +187,7 @@ const componentInfo = {
|
|
|
186
187
|
]
|
|
187
188
|
}
|
|
188
189
|
],
|
|
189
|
-
onChange(options) {
|
|
190
|
+
onChange: markSerializable((options) => {
|
|
190
191
|
function clearWidths() {
|
|
191
192
|
columns.forEach((col) => {
|
|
192
193
|
col.delete("width");
|
|
@@ -210,7 +211,7 @@ const componentInfo = {
|
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
|
-
}
|
|
214
|
+
})
|
|
214
215
|
},
|
|
215
216
|
{
|
|
216
217
|
name: "space",
|
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
import { onMount } from "solid-js";
|
|
2
|
-
import { createMutable } from "solid-js/store";
|
|
1
|
+
import { onMount, createSignal } from "solid-js";
|
|
3
2
|
|
|
4
3
|
function CustomCode(props) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (script.src) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
console.warn("`CustomCode`: Error running script:", error);
|
|
37
|
-
}
|
|
4
|
+
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
5
|
+
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
6
|
+
|
|
7
|
+
function findAndRunScripts() {
|
|
8
|
+
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
9
|
+
if (elem && typeof window !== "undefined") {
|
|
10
|
+
const scripts = elem.getElementsByTagName("script");
|
|
11
|
+
|
|
12
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
13
|
+
const script = scripts[i];
|
|
14
|
+
|
|
15
|
+
if (script.src) {
|
|
16
|
+
if (scriptsInserted().includes(script.src)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
scriptsInserted().push(script.src);
|
|
21
|
+
const newScript = document.createElement("script");
|
|
22
|
+
newScript.async = true;
|
|
23
|
+
newScript.src = script.src;
|
|
24
|
+
document.head.appendChild(newScript);
|
|
25
|
+
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
26
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
scriptsRun().push(script.innerText);
|
|
32
|
+
new Function(script.innerText)();
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
}
|
|
39
|
+
}
|
|
42
40
|
|
|
43
|
-
});
|
|
44
41
|
let elem;
|
|
45
42
|
onMount(() => {
|
|
46
|
-
|
|
43
|
+
findAndRunScripts();
|
|
47
44
|
});
|
|
48
45
|
return <div class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")} ref={elem} innerHTML={props.code}></div>;
|
|
49
46
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markSerializable } from "../util";
|
|
1
2
|
const componentInfo = {
|
|
2
3
|
name: "Embed",
|
|
3
4
|
static: true,
|
|
@@ -9,7 +10,7 @@ const componentInfo = {
|
|
|
9
10
|
required: true,
|
|
10
11
|
defaultValue: "",
|
|
11
12
|
helperText: "e.g. enter a youtube url, google map, etc",
|
|
12
|
-
onChange(options) {
|
|
13
|
+
onChange: markSerializable((options) => {
|
|
13
14
|
const url = options.get("url");
|
|
14
15
|
if (url) {
|
|
15
16
|
options.set("content", "Loading...");
|
|
@@ -28,7 +29,7 @@ const componentInfo = {
|
|
|
28
29
|
} else {
|
|
29
30
|
options.delete("content");
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
})
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
name: "content",
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import { on, createEffect } from "solid-js";
|
|
2
|
-
import { createMutable } from "solid-js/store";
|
|
1
|
+
import { on, createEffect, createSignal } from "solid-js";
|
|
3
2
|
import { isJsScript } from "./helpers";
|
|
4
3
|
|
|
5
4
|
function Embed(props) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
console.warn("`Embed`: Error running script:", error);
|
|
29
|
-
}
|
|
5
|
+
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
6
|
+
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
7
|
+
const [ranInitFn, setRanInitFn] = createSignal(false);
|
|
8
|
+
|
|
9
|
+
function findAndRunScripts() {
|
|
10
|
+
const scripts = elem.getElementsByTagName("script");
|
|
11
|
+
|
|
12
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
13
|
+
const script = scripts[i];
|
|
14
|
+
|
|
15
|
+
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
16
|
+
scriptsInserted().push(script.src);
|
|
17
|
+
const newScript = document.createElement("script");
|
|
18
|
+
newScript.async = true;
|
|
19
|
+
newScript.src = script.src;
|
|
20
|
+
document.head.appendChild(newScript);
|
|
21
|
+
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
22
|
+
try {
|
|
23
|
+
scriptsRun().push(script.innerText);
|
|
24
|
+
new Function(script.innerText)();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.warn("`Embed`: Error running script:", error);
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
}
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
});
|
|
35
32
|
let elem;
|
|
36
33
|
|
|
37
34
|
function onUpdateFn_0() {
|
|
38
|
-
if (elem && !
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (elem && !ranInitFn()) {
|
|
36
|
+
setRanInitFn(true);
|
|
37
|
+
findAndRunScripts();
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
createEffect(on(() => [elem,
|
|
41
|
+
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
45
42
|
return <div class="builder-embed" ref={elem} innerHTML={props.content}></div>;
|
|
46
43
|
}
|
|
47
44
|
|