@builder.io/sdk-svelte 0.0.1-0 → 0.0.1-3
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 +15 -4
- package/src/blocks/{button.svelte → button/button.svelte} +29 -18
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/button/index.js +7 -0
- package/src/blocks/{columns.svelte → columns/columns.svelte} +21 -13
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/columns/index.js +7 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/custom-code/custom-code.svelte +64 -0
- package/src/blocks/custom-code/index.js +7 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/embed/embed.svelte +63 -0
- package/src/blocks/embed/index.js +7 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/{form.svelte → form/form.svelte} +49 -16
- package/src/blocks/form/index.js +7 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/{fragment.svelte → fragment/fragment.svelte} +5 -2
- package/src/blocks/fragment/index.js +7 -0
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/{image.svelte → image/image.svelte} +27 -9
- package/src/blocks/image/index.js +7 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/{img.svelte → img/img.svelte} +5 -2
- package/src/blocks/img/index.js +7 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/index.js +7 -0
- package/src/blocks/{input.svelte → input/input.svelte} +5 -2
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/index.js +7 -0
- package/src/blocks/{raw-text.svelte → raw-text/raw-text.svelte} +4 -1
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/index.js +7 -0
- package/src/blocks/{section.svelte → section/section.svelte} +4 -1
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/index.js +7 -0
- package/src/blocks/{select.svelte → select/select.svelte} +10 -3
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/index.js +7 -0
- package/src/blocks/{submit-button.svelte → submit-button/submit-button.svelte} +4 -1
- package/src/blocks/symbol/component-info.js +42 -0
- package/src/blocks/symbol/index.js +7 -0
- package/src/blocks/symbol/symbol.svelte +54 -0
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/index.js +7 -0
- package/src/blocks/{text.svelte → text/text.svelte} +4 -1
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/index.js +7 -0
- package/src/blocks/{textarea.svelte → textarea/textarea.svelte} +4 -1
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/index.js +7 -0
- package/src/blocks/{video.svelte → video/video.svelte} +4 -1
- package/src/components/error-boundary.svelte +4 -1
- package/src/components/render-block/block-styles.svelte +51 -0
- package/src/components/{render-block.svelte → render-block/render-block.svelte} +60 -18
- package/src/components/render-blocks.svelte +18 -6
- package/src/components/render-content/components/render-styles.svelte +8 -13
- package/src/components/render-content/render-content.svelte +186 -174
- package/src/components/render-inlined-styles.svelte +49 -0
- package/src/constants/device-sizes.js +4 -11
- package/src/constants/target.js +3 -10
- package/src/context/builder.context.js +6 -31
- package/src/functions/evaluate.js +8 -31
- package/src/functions/event-handler-name.js +3 -10
- package/src/functions/get-block-actions.js +6 -29
- package/src/functions/get-block-component-options.js +3 -9
- package/src/functions/get-block-properties.js +3 -9
- package/src/functions/get-block-styles.js +6 -27
- package/src/functions/get-block-tag.js +3 -10
- package/src/functions/get-builder-search-params/fn.test.js +3 -21
- package/src/functions/get-builder-search-params/index.js +4 -11
- package/src/functions/get-content/fn.test.js +3 -21
- package/src/functions/get-content/index.js +8 -28
- package/src/functions/get-fetch.js +31 -32
- package/src/functions/get-global-this.js +3 -10
- package/src/functions/get-processed-block.js +9 -30
- package/src/functions/get-processed-block.test.js +2 -20
- package/src/functions/if-target.js +5 -28
- package/src/functions/is-browser.js +3 -10
- package/src/functions/is-editing.js +5 -28
- package/src/functions/is-iframe.js +5 -28
- package/src/functions/is-previewing.js +7 -30
- package/src/functions/macro-eval.js +3 -10
- package/src/functions/on-change.js +4 -11
- package/src/functions/on-change.test.js +4 -22
- package/src/functions/previewing-model-name.js +5 -28
- package/src/functions/register-component.js +6 -27
- package/src/functions/register.js +5 -28
- package/src/functions/set-editor-settings.js +5 -28
- package/src/functions/set.js +3 -10
- package/src/functions/set.test.js +4 -22
- package/src/functions/track.js +8 -31
- package/src/functions/transform-block.js +3 -10
- package/src/index-helpers/blocks-exports.js +19 -42
- package/src/index-helpers/top-of-file.js +3 -10
- package/src/index.js +10 -32
- package/src/scripts/init-editing.js +72 -81
- package/src/types/builder-block.js +0 -3
- package/src/types/builder-content.js +0 -3
- package/src/types/deep-partial.js +0 -3
- package/src/types/targets.js +0 -3
- package/src/types/typescript.js +0 -3
- package/src/blocks/custom-code.svelte +0 -63
- package/src/blocks/embed.svelte +0 -62
- package/src/blocks/symbol.svelte +0 -55
- package/src/components/block-styles.svelte +0 -23
package/package.json
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-svelte",
|
|
3
3
|
"description": "Builder.io SDK for Svelte",
|
|
4
|
-
"version": "0.0.1-
|
|
5
|
-
"
|
|
6
|
-
|
|
4
|
+
"version": "0.0.1-3",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"main": "./src/index.js",
|
|
10
|
+
"module": "./src/index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./src/index.js",
|
|
14
|
+
"require": "./src/index.js"
|
|
15
|
+
}
|
|
7
16
|
},
|
|
8
|
-
"main": "src/index.js",
|
|
9
17
|
"scripts": {
|
|
10
18
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"node-fetch": "^2.6.1"
|
|
11
22
|
}
|
|
12
23
|
}
|
|
@@ -1,38 +1,49 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
2
6
|
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
export let attributes;
|
|
12
13
|
export let text;
|
|
13
14
|
export let link;
|
|
14
15
|
export let openLinkInNewTab;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
|
|
29
|
+
</script>
|
|
24
30
|
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
|
|
28
33
|
|
|
29
|
-
|
|
30
34
|
{#if link }
|
|
31
|
-
|
|
32
|
-
<a {...attributes} role="button" href={link} target={openLinkInNewTab ? '_blank' : undefined} >
|
|
35
|
+
|
|
33
36
|
|
|
37
|
+
<a {...attributes} role="button" href={link} target={openLinkInNewTab ? '_blank' : undefined} >
|
|
38
|
+
|
|
34
39
|
{text}
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
</a>
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
{:else}
|
|
47
|
+
<span {...attributes}>{text}</span>
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Core:Button",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
5
|
+
defaultStyles: {
|
|
6
|
+
appearance: "none",
|
|
7
|
+
paddingTop: "15px",
|
|
8
|
+
paddingBottom: "15px",
|
|
9
|
+
paddingLeft: "25px",
|
|
10
|
+
paddingRight: "25px",
|
|
11
|
+
backgroundColor: "#000000",
|
|
12
|
+
color: "white",
|
|
13
|
+
borderRadius: "4px",
|
|
14
|
+
textAlign: "center",
|
|
15
|
+
cursor: "pointer"
|
|
16
|
+
},
|
|
17
|
+
inputs: [
|
|
18
|
+
{
|
|
19
|
+
name: "text",
|
|
20
|
+
type: "text",
|
|
21
|
+
defaultValue: "Click me!",
|
|
22
|
+
bubble: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "link",
|
|
26
|
+
type: "url",
|
|
27
|
+
bubble: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "openLinkInNewTab",
|
|
31
|
+
type: "boolean",
|
|
32
|
+
defaultValue: false,
|
|
33
|
+
friendlyName: "Open link in new tab"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
static: true,
|
|
37
|
+
noWrap: true
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
componentInfo
|
|
41
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import component from "./button.svelte";
|
|
3
|
+
import { componentInfo } from "./component-info.js";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import RenderBlocks, { } from '
|
|
6
|
+
import RenderBlocks, { } from '../../components/render-blocks.svelte';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
export let space;
|
|
13
14
|
export let columns;
|
|
14
15
|
export let stackColumnsAt;
|
|
15
16
|
export let reverseColumnsWhenStacked;
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
function getGutterSize() {
|
|
18
19
|
return typeof space === 'number' ? space || 0 : 20;
|
|
19
20
|
}
|
|
@@ -23,26 +24,27 @@ return columns || [];
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
function getWidth(index) {
|
|
26
|
-
const columns =
|
|
27
|
+
const columns = getColumns();
|
|
27
28
|
return columns[index]?.width || 100 / columns.length;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
function getColumnCssWidth(index) {
|
|
31
|
-
const columns =
|
|
32
|
-
const gutterSize =
|
|
32
|
+
const columns = getColumns();
|
|
33
|
+
const gutterSize = getGutterSize();
|
|
33
34
|
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
34
|
-
return `calc(${
|
|
35
|
+
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
function maybeApplyForTablet(prop) {
|
|
38
|
-
const
|
|
39
|
-
|
|
39
|
+
const _stackColumnsAt = stackColumnsAt || 'tablet';
|
|
40
|
+
|
|
41
|
+
return _stackColumnsAt === 'tablet' ? prop : 'inherit';
|
|
40
42
|
}
|
|
41
43
|
$: columnsCssVars = () => {
|
|
42
44
|
const flexDir = stackColumnsAt === 'never' ? 'inherit' : reverseColumnsWhenStacked ? 'column-reverse' : 'column';
|
|
43
45
|
return {
|
|
44
46
|
'--flex-dir': flexDir,
|
|
45
|
-
'--flex-dir-tablet':
|
|
47
|
+
'--flex-dir-tablet': maybeApplyForTablet(flexDir)
|
|
46
48
|
};
|
|
47
49
|
};
|
|
48
50
|
|
|
@@ -52,12 +54,14 @@ const marginLeft = '0';
|
|
|
52
54
|
return {
|
|
53
55
|
'--column-width': width,
|
|
54
56
|
'--column-margin-left': marginLeft,
|
|
55
|
-
'--column-width-tablet':
|
|
56
|
-
'--column-margin-left-tablet':
|
|
57
|
+
'--column-width-tablet': maybeApplyForTablet(width),
|
|
58
|
+
'--column-margin-left-tablet': maybeApplyForTablet(marginLeft)
|
|
57
59
|
};
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
|
|
63
|
+
|
|
64
|
+
|
|
61
65
|
|
|
62
66
|
|
|
63
67
|
|
|
@@ -68,7 +72,9 @@ return {
|
|
|
68
72
|
|
|
69
73
|
<div class="builder-columns div" style={columnsCssVars()} >
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
|
|
76
|
+
{#each columns as column, index }
|
|
77
|
+
<div class="builder-column div-2" style={{
|
|
72
78
|
width: getColumnCssWidth(index),
|
|
73
79
|
marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
|
|
74
80
|
...columnCssVars()
|
|
@@ -76,7 +82,9 @@ marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
|
|
|
76
82
|
|
|
77
83
|
<RenderBlocks blocks={column.blocks} ></RenderBlocks>
|
|
78
84
|
|
|
79
|
-
</div>
|
|
85
|
+
</div>
|
|
86
|
+
{/each}
|
|
87
|
+
|
|
80
88
|
|
|
81
89
|
</div>
|
|
82
90
|
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Columns",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
inputs: [
|
|
5
|
+
{
|
|
6
|
+
name: "columns",
|
|
7
|
+
type: "array",
|
|
8
|
+
broadcast: true,
|
|
9
|
+
subFields: [
|
|
10
|
+
{
|
|
11
|
+
name: "blocks",
|
|
12
|
+
type: "array",
|
|
13
|
+
hideFromUI: true,
|
|
14
|
+
defaultValue: [
|
|
15
|
+
{
|
|
16
|
+
"@type": "@builder.io/sdk:Element",
|
|
17
|
+
responsiveStyles: {
|
|
18
|
+
large: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
alignItems: "stretch",
|
|
22
|
+
flexShrink: "0",
|
|
23
|
+
position: "relative",
|
|
24
|
+
marginTop: "30px",
|
|
25
|
+
textAlign: "center",
|
|
26
|
+
lineHeight: "normal",
|
|
27
|
+
height: "auto",
|
|
28
|
+
minHeight: "20px",
|
|
29
|
+
minWidth: "20px",
|
|
30
|
+
overflow: "hidden"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
component: {
|
|
34
|
+
name: "Image",
|
|
35
|
+
options: {
|
|
36
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
37
|
+
backgroundPosition: "center",
|
|
38
|
+
backgroundSize: "cover",
|
|
39
|
+
aspectRatio: 0.7004048582995948
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"@type": "@builder.io/sdk:Element",
|
|
45
|
+
responsiveStyles: {
|
|
46
|
+
large: {
|
|
47
|
+
display: "flex",
|
|
48
|
+
flexDirection: "column",
|
|
49
|
+
alignItems: "stretch",
|
|
50
|
+
flexShrink: "0",
|
|
51
|
+
position: "relative",
|
|
52
|
+
marginTop: "30px",
|
|
53
|
+
textAlign: "center",
|
|
54
|
+
lineHeight: "normal",
|
|
55
|
+
height: "auto"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
component: {
|
|
59
|
+
name: "Text",
|
|
60
|
+
options: {
|
|
61
|
+
text: "<p>Enter some text...</p>"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "width",
|
|
69
|
+
type: "number",
|
|
70
|
+
hideFromUI: true,
|
|
71
|
+
helperText: "Width %, e.g. set to 50 to fill half of the space"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "link",
|
|
75
|
+
type: "url",
|
|
76
|
+
helperText: "Optionally set a url that clicking this column will link to"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
defaultValue: [
|
|
80
|
+
{
|
|
81
|
+
blocks: [
|
|
82
|
+
{
|
|
83
|
+
"@type": "@builder.io/sdk:Element",
|
|
84
|
+
responsiveStyles: {
|
|
85
|
+
large: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
flexDirection: "column",
|
|
88
|
+
alignItems: "stretch",
|
|
89
|
+
flexShrink: "0",
|
|
90
|
+
position: "relative",
|
|
91
|
+
marginTop: "30px",
|
|
92
|
+
textAlign: "center",
|
|
93
|
+
lineHeight: "normal",
|
|
94
|
+
height: "auto",
|
|
95
|
+
minHeight: "20px",
|
|
96
|
+
minWidth: "20px",
|
|
97
|
+
overflow: "hidden"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
component: {
|
|
101
|
+
name: "Image",
|
|
102
|
+
options: {
|
|
103
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
104
|
+
backgroundPosition: "center",
|
|
105
|
+
backgroundSize: "cover",
|
|
106
|
+
aspectRatio: 0.7004048582995948
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"@type": "@builder.io/sdk:Element",
|
|
112
|
+
responsiveStyles: {
|
|
113
|
+
large: {
|
|
114
|
+
display: "flex",
|
|
115
|
+
flexDirection: "column",
|
|
116
|
+
alignItems: "stretch",
|
|
117
|
+
flexShrink: "0",
|
|
118
|
+
position: "relative",
|
|
119
|
+
marginTop: "30px",
|
|
120
|
+
textAlign: "center",
|
|
121
|
+
lineHeight: "normal",
|
|
122
|
+
height: "auto"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
component: {
|
|
126
|
+
name: "Text",
|
|
127
|
+
options: {
|
|
128
|
+
text: "<p>Enter some text...</p>"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
blocks: [
|
|
136
|
+
{
|
|
137
|
+
"@type": "@builder.io/sdk:Element",
|
|
138
|
+
responsiveStyles: {
|
|
139
|
+
large: {
|
|
140
|
+
display: "flex",
|
|
141
|
+
flexDirection: "column",
|
|
142
|
+
alignItems: "stretch",
|
|
143
|
+
flexShrink: "0",
|
|
144
|
+
position: "relative",
|
|
145
|
+
marginTop: "30px",
|
|
146
|
+
textAlign: "center",
|
|
147
|
+
lineHeight: "normal",
|
|
148
|
+
height: "auto",
|
|
149
|
+
minHeight: "20px",
|
|
150
|
+
minWidth: "20px",
|
|
151
|
+
overflow: "hidden"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
component: {
|
|
155
|
+
name: "Image",
|
|
156
|
+
options: {
|
|
157
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
158
|
+
backgroundPosition: "center",
|
|
159
|
+
backgroundSize: "cover",
|
|
160
|
+
aspectRatio: 0.7004048582995948
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"@type": "@builder.io/sdk:Element",
|
|
166
|
+
responsiveStyles: {
|
|
167
|
+
large: {
|
|
168
|
+
display: "flex",
|
|
169
|
+
flexDirection: "column",
|
|
170
|
+
alignItems: "stretch",
|
|
171
|
+
flexShrink: "0",
|
|
172
|
+
position: "relative",
|
|
173
|
+
marginTop: "30px",
|
|
174
|
+
textAlign: "center",
|
|
175
|
+
lineHeight: "normal",
|
|
176
|
+
height: "auto"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
component: {
|
|
180
|
+
name: "Text",
|
|
181
|
+
options: {
|
|
182
|
+
text: "<p>Enter some text...</p>"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
onChange: " function clearWidths() { columns.forEach(col => { col.delete('width'); }); } const columns = options.get('columns') as Array<Map<String, any>>; if (Array.isArray(columns)) { const containsColumnWithWidth = !!columns.find(col => col.get('width')); if (containsColumnWithWidth) { const containsColumnWithoutWidth = !!columns.find(col => !col.get('width')); if (containsColumnWithoutWidth) { clearWidths(); } else { const sumWidths = columns.reduce((memo, col) => { return memo + col.get('width'); }, 0); const widthsDontAddUp = sumWidths !== 100; if (widthsDontAddUp) { clearWidths(); } } } } "
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "space",
|
|
193
|
+
type: "number",
|
|
194
|
+
defaultValue: 20,
|
|
195
|
+
helperText: "Size of gap between columns",
|
|
196
|
+
advanced: true
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "stackColumnsAt",
|
|
200
|
+
type: "string",
|
|
201
|
+
defaultValue: "tablet",
|
|
202
|
+
helperText: "Convert horizontal columns to vertical at what device size",
|
|
203
|
+
enum: ["tablet", "mobile", "never"],
|
|
204
|
+
advanced: true
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "reverseColumnsWhenStacked",
|
|
208
|
+
type: "boolean",
|
|
209
|
+
defaultValue: false,
|
|
210
|
+
helperText: "When stacking columns for mobile devices, reverse the ordering",
|
|
211
|
+
advanced: true
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
};
|
|
215
|
+
export {
|
|
216
|
+
componentInfo
|
|
217
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import component from "./columns.svelte";
|
|
3
|
+
import { componentInfo } from "./component-info.js";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Custom Code",
|
|
3
|
+
static: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
requiredPermissions: ["editCode"],
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "code",
|
|
9
|
+
type: "html",
|
|
10
|
+
required: true,
|
|
11
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
12
|
+
code: true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "replaceNodes",
|
|
16
|
+
type: "boolean",
|
|
17
|
+
helperText: "Preserve server rendered dom nodes",
|
|
18
|
+
advanced: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "scriptsClientOnly",
|
|
22
|
+
type: "boolean",
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
25
|
+
advanced: true
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
componentInfo
|
|
31
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export let elem;
|
|
13
|
+
export let replaceNodes;
|
|
14
|
+
export let code;
|
|
15
|
+
|
|
16
|
+
function findAndRunScripts() {
|
|
17
|
+
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
18
|
+
if (elem && typeof window !== 'undefined') {
|
|
19
|
+
/** @type {HTMLScriptElement[]} */
|
|
20
|
+
const scripts = elem.getElementsByTagName('script');
|
|
21
|
+
|
|
22
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
23
|
+
const script = scripts[i];
|
|
24
|
+
|
|
25
|
+
if (script.src) {
|
|
26
|
+
if (scriptsInserted.includes(script.src)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
scriptsInserted.push(script.src);
|
|
31
|
+
const newScript = document.createElement('script');
|
|
32
|
+
newScript.async = true;
|
|
33
|
+
newScript.src = script.src;
|
|
34
|
+
document.head.appendChild(newScript);
|
|
35
|
+
} else if (!script.type || ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(script.type)) {
|
|
36
|
+
if (scriptsRun.includes(script.innerText)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
scriptsRun.push(script.innerText);
|
|
42
|
+
new Function(script.innerText)();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.warn('`CustomCode`: Error running script:', error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
let scriptsInserted = [];
|
|
55
|
+
let scriptsRun = [];
|
|
56
|
+
|
|
57
|
+
onMount(() => { findAndRunScripts(); });
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div bind:this={elem} class={'builder-custom-code' + (replaceNodes ? ' replace-nodes' : '')} >{@html code}</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import { componentInfo } from "./component-info.js";
|
|
3
|
+
import component from "./custom-code.svelte";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Embed",
|
|
3
|
+
static: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
name: "url",
|
|
8
|
+
type: "url",
|
|
9
|
+
required: true,
|
|
10
|
+
defaultValue: "",
|
|
11
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
12
|
+
onChange: " const url = options.get('url'); if (url) { options.set('content', 'Loading...'); // TODO: get this out of here! const apiKey = 'ae0e60e78201a3f2b0de4b'; return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`) .then(res => res.json()) .then(data => { if (options.get('url') === url) { if (data.html) { options.set('content', data.html); } else { options.set('content', 'Invalid url, please try another'); } } }) .catch(err => { options.set( 'content', 'There was an error embedding this URL, please try again or another URL' ); }); } else { options.delete('content'); } "
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "content",
|
|
16
|
+
type: "html",
|
|
17
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
18
|
+
hideFromUI: true
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
componentInfo
|
|
24
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export let elem;
|
|
13
|
+
export let content;
|
|
14
|
+
|
|
15
|
+
function findAndRunScripts() {
|
|
16
|
+
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
17
|
+
if (elem && typeof window !== 'undefined') {
|
|
18
|
+
/** @type {HTMLScriptElement[]} */
|
|
19
|
+
const scripts = elem.getElementsByTagName('script');
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
22
|
+
const script = scripts[i];
|
|
23
|
+
|
|
24
|
+
if (script.src) {
|
|
25
|
+
if (scriptsInserted.includes(script.src)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
scriptsInserted.push(script.src);
|
|
30
|
+
const newScript = document.createElement('script');
|
|
31
|
+
newScript.async = true;
|
|
32
|
+
newScript.src = script.src;
|
|
33
|
+
document.head.appendChild(newScript);
|
|
34
|
+
} else if (!script.type || ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(script.type)) {
|
|
35
|
+
if (scriptsRun.includes(script.innerText)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
scriptsRun.push(script.innerText);
|
|
41
|
+
new Function(script.innerText)();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.warn('`Embed`: Error running script:', error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
let scriptsInserted = [];
|
|
54
|
+
let scriptsRun = [];
|
|
55
|
+
|
|
56
|
+
onMount(() => { findAndRunScripts(); });
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<div class="builder-embed" bind:this={elem} >{@html content}</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerComponent } from "../../functions/register-component.js";
|
|
2
|
+
import { componentInfo } from "./component-info.js";
|
|
3
|
+
import component from "./embed.svelte";
|
|
4
|
+
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
+
export {
|
|
6
|
+
stdin_default as default
|
|
7
|
+
};
|