@builder.io/sdk-svelte 0.0.1-20 → 0.0.1-23
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/button/button.svelte +17 -48
- package/src/blocks/columns/columns.svelte +110 -102
- package/src/blocks/columns/component-info.js +25 -1
- package/src/blocks/custom-code/custom-code.svelte +59 -61
- package/src/blocks/embed/component-info.js +20 -1
- package/src/blocks/embed/embed.svelte +38 -56
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/form.svelte +264 -294
- package/src/blocks/fragment/fragment.svelte +1 -26
- package/src/blocks/image/component-info.js +47 -1
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.svelte +121 -117
- package/src/blocks/img/img.svelte +22 -32
- package/src/blocks/input/input.svelte +17 -30
- package/src/blocks/raw-text/raw-text.svelte +4 -26
- package/src/blocks/section/section.svelte +20 -36
- package/src/blocks/select/select.svelte +16 -36
- package/src/blocks/submit-button/submit-button.svelte +4 -30
- package/src/blocks/symbol/symbol.svelte +57 -57
- package/src/blocks/text/text.svelte +1 -25
- package/src/blocks/textarea/textarea.svelte +5 -29
- package/src/blocks/video/video.svelte +35 -43
- package/src/components/render-block/block-styles.svelte +49 -59
- package/src/components/render-block/render-block.svelte +197 -167
- package/src/components/render-block/render-component.svelte +13 -51
- package/src/components/render-block/render-repeated-block.svelte +29 -0
- package/src/components/render-blocks.svelte +74 -98
- package/src/components/render-content/components/render-styles.svelte +42 -62
- package/src/components/render-content/render-content.svelte +252 -241
- package/src/components/render-inlined-styles.svelte +15 -45
- package/src/constants/builder-registered-components.js +4 -1
- package/src/context/builder.context.js +7 -1
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/get-block-styles.js +6 -3
- package/src/functions/get-processed-block.js +15 -8
- package/src/functions/get-processed-block.test.js +2 -1
- package/src/functions/register-component.js +10 -18
- package/src/functions/sanitize-styles.js +5 -0
- package/src/functions/fast-clone.js +0 -4
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import RenderInlinedStyles from '../../render-inlined-styles.svelte';
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import RenderInlinedStyles from "../../render-inlined-styles.svelte";
|
|
9
3
|
|
|
10
|
-
|
|
4
|
+
export let cssCode;
|
|
5
|
+
export let customFonts;
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const url = font.fileUrl ?? font?.files?.regular;
|
|
21
|
-
let str = '';
|
|
7
|
+
const getCssFromFont = function getCssFromFont(font) {
|
|
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 = "";
|
|
22
15
|
|
|
23
|
-
if (url && family && name) {
|
|
24
|
-
|
|
16
|
+
if (url && family && name) {
|
|
17
|
+
str += `
|
|
25
18
|
@font-face {
|
|
26
19
|
font-family: "${family}";
|
|
27
20
|
src: local("${name}"), url('${url}') format('woff2');
|
|
@@ -29,21 +22,20 @@ if (url && family && name) {
|
|
|
29
22
|
font-weight: 400;
|
|
30
23
|
}
|
|
31
24
|
`.trim();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (font.files) {
|
|
35
|
-
for (const weight in font.files) {
|
|
36
|
-
const isNumber = String(Number(weight)) === weight;
|
|
25
|
+
}
|
|
37
26
|
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
if (font.files) {
|
|
28
|
+
for (const weight in font.files) {
|
|
29
|
+
const isNumber = String(Number(weight)) === weight;
|
|
41
30
|
|
|
31
|
+
if (!isNumber) {
|
|
32
|
+
continue;
|
|
33
|
+
} // TODO: maybe limit number loaded
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
const weightUrl = font.files[weight];
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
if (weightUrl && weightUrl !== url) {
|
|
38
|
+
str += `
|
|
47
39
|
@font-face {
|
|
48
40
|
font-family: "${family}";
|
|
49
41
|
src: url('${weightUrl}') format('woff2');
|
|
@@ -51,40 +43,28 @@ if (font.files) {
|
|
|
51
43
|
font-weight: ${weight};
|
|
52
44
|
}
|
|
53
45
|
`.trim();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
54
48
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
49
|
|
|
58
|
-
return str;
|
|
59
|
-
};
|
|
50
|
+
return str;
|
|
51
|
+
};
|
|
60
52
|
|
|
61
|
-
const getFontCss = function getFontCss({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return `
|
|
73
|
-
${cssCode || ''}
|
|
53
|
+
const getFontCss = function getFontCss({ customFonts }) {
|
|
54
|
+
// TODO: flag for this
|
|
55
|
+
// if (!builder.allowCustomFonts) {
|
|
56
|
+
// return '';
|
|
57
|
+
// }
|
|
58
|
+
// TODO: separate internal data from external
|
|
59
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
60
|
+
};
|
|
61
|
+
$: injectedStyles = () => {
|
|
62
|
+
return `
|
|
63
|
+
${cssCode || ""}
|
|
74
64
|
${getFontCss({
|
|
75
|
-
customFonts: customFonts
|
|
65
|
+
customFonts: customFonts,
|
|
76
66
|
})}`;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
</script>
|
|
67
|
+
};
|
|
68
|
+
</script>
|
|
89
69
|
|
|
90
|
-
|
|
70
|
+
<RenderInlinedStyles styles={injectedStyles()} />
|
|
@@ -1,267 +1,278 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { getDefaultRegisteredComponents } from
|
|
7
|
-
import { TARGET } from
|
|
8
|
-
import BuilderContext from
|
|
9
|
-
import { evaluate } from
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export let
|
|
31
|
-
export let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { afterUpdate } from "svelte";
|
|
4
|
+
import { onDestroy } from "svelte";
|
|
5
|
+
|
|
6
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
7
|
+
import { TARGET } from "../../constants/target.js";
|
|
8
|
+
import BuilderContext from "../../context/builder.context";
|
|
9
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
10
|
+
import {
|
|
11
|
+
convertSearchParamsToQueryObject,
|
|
12
|
+
getBuilderSearchParams,
|
|
13
|
+
} from "../../functions/get-builder-search-params/index.js";
|
|
14
|
+
import { getContent } from "../../functions/get-content/index.js";
|
|
15
|
+
import { getFetch } from "../../functions/get-fetch.js";
|
|
16
|
+
import { isBrowser } from "../../functions/is-browser.js";
|
|
17
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
18
|
+
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
19
|
+
import { previewingModelName } from "../../functions/previewing-model-name.js";
|
|
20
|
+
import {
|
|
21
|
+
components,
|
|
22
|
+
createRegisterComponentMessage,
|
|
23
|
+
} from "../../functions/register-component.js";
|
|
24
|
+
import { track } from "../../functions/track.js";
|
|
25
|
+
import RenderBlocks from "../render-blocks.svelte";
|
|
26
|
+
import RenderContentStyles from "./components/render-styles.svelte";
|
|
27
|
+
|
|
28
|
+
import { getContext, setContext } from "svelte";
|
|
29
|
+
|
|
30
|
+
export let content;
|
|
31
|
+
export let data;
|
|
32
|
+
export let context;
|
|
33
|
+
export let customComponents;
|
|
34
|
+
export let model;
|
|
35
|
+
export let apiKey;
|
|
36
|
+
|
|
37
|
+
const processMessage = function processMessage(event) {
|
|
38
|
+
const { data } = event;
|
|
39
|
+
|
|
40
|
+
if (data) {
|
|
41
|
+
switch (data.type) {
|
|
42
|
+
case "builder.contentUpdate": {
|
|
43
|
+
const messageContent = data.data;
|
|
44
|
+
const key =
|
|
45
|
+
messageContent.key ||
|
|
46
|
+
messageContent.alias ||
|
|
47
|
+
messageContent.entry ||
|
|
48
|
+
messageContent.modelName;
|
|
49
|
+
const contentData = messageContent.data;
|
|
50
|
+
|
|
51
|
+
if (key === model) {
|
|
52
|
+
overrideContent = contentData;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
break;
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
case "builder.patchUpdates": {
|
|
59
|
+
// TODO
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
51
62
|
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
66
|
+
const evaluateJsCode = function evaluateJsCode() {
|
|
67
|
+
// run any dynamic JS code attached to content
|
|
68
|
+
const jsCode = useContent?.()?.data?.jsCode;
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
if (jsCode) {
|
|
71
|
+
evaluate({
|
|
72
|
+
code: jsCode,
|
|
73
|
+
context: contextContext(),
|
|
74
|
+
state: contentState(),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
65
78
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
79
|
+
const evalExpression = function evalExpression(expression) {
|
|
80
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
|
|
81
|
+
evaluate({
|
|
82
|
+
code: group,
|
|
83
|
+
context: contextContext(),
|
|
84
|
+
state: contentState(),
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
};
|
|
74
88
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
89
|
+
const handleRequest = function handleRequest({ url, key }) {
|
|
90
|
+
const fetchAndSetState = async () => {
|
|
91
|
+
const fetch = await getFetch();
|
|
92
|
+
const response = await fetch(url);
|
|
93
|
+
const json = await response.json();
|
|
94
|
+
const newOverrideState = { ...overrideState, [key]: json };
|
|
95
|
+
overrideState = newOverrideState;
|
|
96
|
+
};
|
|
82
97
|
|
|
83
|
-
|
|
84
|
-
url,
|
|
85
|
-
key
|
|
86
|
-
}) {
|
|
87
|
-
const fetchAndSetState = async () => {
|
|
88
|
-
const fetch = await getFetch();
|
|
89
|
-
const response = await fetch(url);
|
|
90
|
-
const json = await response.json();
|
|
91
|
-
const newOverrideState = { ...overrideState,
|
|
92
|
-
[key]: json
|
|
98
|
+
fetchAndSetState();
|
|
93
99
|
};
|
|
94
|
-
overrideState = newOverrideState;
|
|
95
|
-
};
|
|
96
100
|
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
key
|
|
101
|
+
const runHttpRequests = function runHttpRequests() {
|
|
102
|
+
const requests = useContent?.()?.data?.httpRequests ?? {};
|
|
103
|
+
Object.entries(requests).forEach(([key, url]) => {
|
|
104
|
+
if (url && (!httpReqsData()[key] || isEditing())) {
|
|
105
|
+
const evaluatedUrl = evalExpression(url);
|
|
106
|
+
handleRequest({
|
|
107
|
+
url: evaluatedUrl,
|
|
108
|
+
key,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
108
111
|
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
+
};
|
|
112
113
|
|
|
113
|
-
const emitStateUpdate = function emitStateUpdate() {
|
|
114
|
-
if (isEditing()) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
const emitStateUpdate = function emitStateUpdate() {
|
|
115
|
+
if (isEditing()) {
|
|
116
|
+
window.dispatchEvent(
|
|
117
|
+
new CustomEvent("builder:component:stateChange", {
|
|
118
|
+
detail: {
|
|
119
|
+
state: contentState(),
|
|
120
|
+
ref: {
|
|
121
|
+
name: model,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
);
|
|
121
126
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
return mergedContent;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
$: contentState = () => {
|
|
137
|
-
return { ...content?.data?.state,
|
|
138
|
-
...data,
|
|
139
|
-
...overrideState
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
$: context = () => {
|
|
144
|
-
return {};
|
|
145
|
-
};
|
|
127
|
+
};
|
|
128
|
+
$: useContent = () => {
|
|
129
|
+
const mergedContent = {
|
|
130
|
+
...content,
|
|
131
|
+
...overrideContent,
|
|
132
|
+
data: { ...content?.data, ...data, ...overrideContent?.data },
|
|
133
|
+
};
|
|
134
|
+
return mergedContent;
|
|
135
|
+
};
|
|
146
136
|
|
|
147
|
-
$:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// existing usage.
|
|
151
|
-
// This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
|
|
152
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
153
|
-
...components, ...(customComponents || [])];
|
|
154
|
-
const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,
|
|
155
|
-
[curr.name]: curr
|
|
156
|
-
}), {});
|
|
157
|
-
return allComponents;
|
|
158
|
-
};
|
|
137
|
+
$: contentState = () => {
|
|
138
|
+
return { ...content?.data?.state, ...data, ...overrideState };
|
|
139
|
+
};
|
|
159
140
|
|
|
160
|
-
$:
|
|
161
|
-
return {};
|
|
162
|
-
};
|
|
141
|
+
$: contextContext = () => {
|
|
142
|
+
return context || {};
|
|
143
|
+
};
|
|
163
144
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
145
|
+
$: allRegisteredComponents = () => {
|
|
146
|
+
const allComponentsArray = [
|
|
147
|
+
...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
|
|
148
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
149
|
+
// existing usage.
|
|
150
|
+
// This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
|
|
151
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
152
|
+
...components,
|
|
153
|
+
...(customComponents || []),
|
|
154
|
+
];
|
|
155
|
+
const allComponents = allComponentsArray.reduce(
|
|
156
|
+
(acc, curr) => ({ ...acc, [curr.name]: curr }),
|
|
157
|
+
{}
|
|
158
|
+
);
|
|
159
|
+
return allComponents;
|
|
160
|
+
};
|
|
179
161
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const message = createRegisterComponentMessage(registeredComponent);
|
|
184
|
-
window.parent?.postMessage(message, '*');
|
|
185
|
-
});
|
|
186
|
-
window.addEventListener('message', processMessage);
|
|
187
|
-
window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
|
|
188
|
-
}
|
|
162
|
+
$: httpReqsData = () => {
|
|
163
|
+
return {};
|
|
164
|
+
};
|
|
189
165
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
166
|
+
setContext(BuilderContext.key, {
|
|
167
|
+
get content() {
|
|
168
|
+
return useContent();
|
|
169
|
+
},
|
|
170
|
+
get state() {
|
|
171
|
+
return contentState();
|
|
172
|
+
},
|
|
173
|
+
get context() {
|
|
174
|
+
return contextContext();
|
|
175
|
+
},
|
|
176
|
+
get apiKey() {
|
|
177
|
+
return apiKey;
|
|
178
|
+
},
|
|
179
|
+
get registeredComponents() {
|
|
180
|
+
return allRegisteredComponents();
|
|
181
|
+
},
|
|
193
182
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
183
|
+
let overrideContent = null;
|
|
184
|
+
let update = 0;
|
|
185
|
+
let overrideState = {};
|
|
186
|
+
|
|
187
|
+
onMount(() => {
|
|
188
|
+
if (isBrowser()) {
|
|
189
|
+
if (isEditing()) {
|
|
190
|
+
Object.values(allRegisteredComponents()).forEach(
|
|
191
|
+
(registeredComponent) => {
|
|
192
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
193
|
+
window.parent?.postMessage(message, "*");
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
window.addEventListener("message", processMessage);
|
|
197
|
+
window.addEventListener(
|
|
198
|
+
"builder:component:stateChangeListenerActivated",
|
|
199
|
+
emitStateUpdate
|
|
200
|
+
);
|
|
201
|
+
}
|
|
201
202
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
if (useContent()) {
|
|
204
|
+
track("impression", {
|
|
205
|
+
contentId: useContent().id,
|
|
206
|
+
});
|
|
207
|
+
} // override normal content in preview mode
|
|
208
|
+
|
|
209
|
+
if (isPreviewing()) {
|
|
210
|
+
if (model && previewingModelName() === model) {
|
|
211
|
+
const currentUrl = new URL(location.href);
|
|
212
|
+
const previewApiKey = currentUrl.searchParams.get("apiKey");
|
|
213
|
+
|
|
214
|
+
if (previewApiKey) {
|
|
215
|
+
getContent({
|
|
216
|
+
model: model,
|
|
217
|
+
apiKey: previewApiKey,
|
|
218
|
+
options: getBuilderSearchParams(
|
|
219
|
+
convertSearchParamsToQueryObject(currentUrl.searchParams)
|
|
220
|
+
),
|
|
221
|
+
}).then((content) => {
|
|
222
|
+
if (content) {
|
|
223
|
+
overrideContent = content;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
210
227
|
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
evaluateJsCode();
|
|
217
|
-
runHttpRequests();
|
|
218
|
-
emitStateUpdate();
|
|
219
|
-
} });
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
function onUpdateFn_0() {
|
|
223
|
-
evaluateJsCode();
|
|
224
|
-
}
|
|
225
|
-
$: onUpdateFn_0(...[useContent?.()?.data?.jsCode])
|
|
226
|
-
;
|
|
227
|
-
function onUpdateFn_1() {
|
|
228
|
-
runHttpRequests();
|
|
229
|
-
}
|
|
230
|
-
$: onUpdateFn_1(...[useContent?.()?.data?.httpRequests])
|
|
231
|
-
;
|
|
232
|
-
function onUpdateFn_2() {
|
|
233
|
-
emitStateUpdate();
|
|
234
|
-
}
|
|
235
|
-
$: onUpdateFn_2(...[contentState()])
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
onDestroy(() => { if (isBrowser()) {
|
|
239
|
-
window.removeEventListener('message', processMessage);
|
|
240
|
-
window.removeEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
|
|
241
|
-
} });
|
|
242
|
-
</script>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
{#if useContent() }
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<div on:click="{event => track('click', {
|
|
249
|
-
contentId: useContent().id
|
|
250
|
-
})}" data-builder-content-id={useContent?.()?.id} >
|
|
251
|
-
|
|
228
|
+
}
|
|
252
229
|
|
|
253
|
-
|
|
254
|
-
|
|
230
|
+
evaluateJsCode();
|
|
231
|
+
runHttpRequests();
|
|
232
|
+
emitStateUpdate();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
255
235
|
|
|
236
|
+
function onUpdateFn_0() {
|
|
237
|
+
evaluateJsCode();
|
|
238
|
+
}
|
|
239
|
+
$: onUpdateFn_0(...[useContent?.()?.data?.jsCode]);
|
|
240
|
+
function onUpdateFn_1() {
|
|
241
|
+
runHttpRequests();
|
|
242
|
+
}
|
|
243
|
+
$: onUpdateFn_1(...[useContent?.()?.data?.httpRequests]);
|
|
244
|
+
function onUpdateFn_2() {
|
|
245
|
+
emitStateUpdate();
|
|
246
|
+
}
|
|
247
|
+
$: onUpdateFn_2(...[contentState()]);
|
|
248
|
+
|
|
249
|
+
onDestroy(() => {
|
|
250
|
+
if (isBrowser()) {
|
|
251
|
+
window.removeEventListener("message", processMessage);
|
|
252
|
+
window.removeEventListener(
|
|
253
|
+
"builder:component:stateChangeListenerActivated",
|
|
254
|
+
emitStateUpdate
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
</script>
|
|
256
259
|
|
|
260
|
+
{#if useContent()}
|
|
261
|
+
<div
|
|
262
|
+
on:click={(event) => {
|
|
263
|
+
track("click", {
|
|
264
|
+
contentId: useContent().id,
|
|
265
|
+
});
|
|
266
|
+
}}
|
|
267
|
+
data-builder-content-id={useContent?.()?.id}
|
|
268
|
+
>
|
|
269
|
+
{#if (useContent?.()?.data?.cssCode || useContent?.()?.data?.customFonts?.length) && TARGET !== "reactNative"}
|
|
270
|
+
<RenderContentStyles
|
|
271
|
+
cssCode={useContent().data.cssCode}
|
|
272
|
+
customFonts={useContent().data.customFonts}
|
|
273
|
+
/>
|
|
274
|
+
{/if}
|
|
275
|
+
|
|
276
|
+
<RenderBlocks blocks={useContent?.()?.data?.blocks} />
|
|
277
|
+
</div>
|
|
257
278
|
{/if}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
<RenderBlocks blocks={useContent?.()?.data?.blocks} ></RenderBlocks>
|
|
261
|
-
|
|
262
|
-
</div>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
{/if}
|