@builder.io/sdk-svelte 0.0.1-2 → 0.0.1-22
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/README.md +19 -0
- package/package.json +22 -4
- package/src/blocks/button/button.svelte +17 -47
- package/src/blocks/columns/columns.svelte +110 -102
- 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 -25
- package/src/blocks/image/image.svelte +85 -116
- package/src/blocks/img/img.svelte +25 -35
- package/src/blocks/input/input.svelte +17 -30
- package/src/blocks/raw-text/raw-text.svelte +4 -25
- package/src/blocks/section/section.svelte +20 -35
- package/src/blocks/select/select.svelte +16 -36
- package/src/blocks/submit-button/submit-button.svelte +4 -29
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.svelte +57 -52
- package/src/blocks/text/text.svelte +1 -24
- package/src/blocks/textarea/textarea.svelte +5 -28
- package/src/blocks/video/video.svelte +35 -42
- package/src/components/render-block/block-styles.svelte +54 -50
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.svelte +198 -159
- package/src/components/render-block/render-component.svelte +20 -0
- package/src/components/render-block/render-repeated-block.svelte +29 -0
- package/src/components/render-blocks.svelte +74 -79
- package/src/components/render-content/components/render-styles.svelte +43 -63
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.svelte +258 -208
- package/src/components/render-inlined-styles.svelte +15 -43
- package/src/constants/builder-registered-components.js +48 -0
- package/src/constants/device-sizes.js +3 -21
- package/src/context/builder.context.js +7 -1
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/evaluate.js +2 -2
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +7 -4
- package/src/functions/get-content/index.js +1 -1
- package/src/functions/get-fetch.js +1 -1
- package/src/functions/get-processed-block.js +18 -11
- package/src/functions/get-processed-block.test.js +3 -2
- package/src/functions/if-target.js +1 -1
- package/src/functions/is-editing.js +1 -1
- package/src/functions/is-iframe.js +1 -1
- package/src/functions/is-previewing.js +2 -2
- package/src/functions/on-change.test.js +1 -1
- package/src/functions/previewing-model-name.js +1 -1
- package/src/functions/register-component.js +35 -26
- package/src/functions/register.js +1 -1
- package/src/functions/sanitize-styles.js +5 -0
- package/src/functions/set-editor-settings.js +1 -1
- package/src/functions/set.test.js +1 -1
- package/src/functions/track.js +3 -3
- package/src/helpers/css.js +12 -0
- package/src/index-helpers/blocks-exports.js +10 -8
- package/src/index.js +10 -10
- package/src/scripts/init-editing.js +4 -4
- 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/components/error-boundary.svelte +0 -26
- package/src/functions/macro-eval.js +0 -5
|
@@ -1,228 +1,278 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
45
56
|
}
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
// TODO
|
|
53
|
-
break;
|
|
58
|
+
case "builder.patchUpdates": {
|
|
59
|
+
// TODO
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function evaluateJsCode() {
|
|
60
|
-
// run any dynamic JS code attached to content
|
|
61
|
-
const jsCode = useContent?.()?.data?.jsCode;
|
|
62
|
-
|
|
63
|
-
if (jsCode) {
|
|
64
|
-
evaluate({
|
|
65
|
-
code: jsCode,
|
|
66
|
-
context: context(),
|
|
67
|
-
state: contentState()
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function evalExpression(expression) {
|
|
73
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
74
|
-
code: group,
|
|
75
|
-
context: context(),
|
|
76
|
-
state: contentState()
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function handleRequest({
|
|
81
|
-
url,
|
|
82
|
-
key
|
|
83
|
-
}) {
|
|
84
|
-
const fetchAndSetState = async () => {
|
|
85
|
-
const fetch = await getFetch();
|
|
86
|
-
const response = await fetch(url);
|
|
87
|
-
const json = await response.json();
|
|
88
|
-
const newOverrideState = { ...overrideState,
|
|
89
|
-
[key]: json
|
|
90
|
-
};
|
|
91
|
-
overrideState = newOverrideState;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
fetchAndSetState();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function runHttpRequests() {
|
|
98
|
-
const requests = useContent?.()?.data?.httpRequests ?? {};
|
|
99
|
-
Object.entries(requests).forEach(([key, url]) => {
|
|
100
|
-
if (url && (!httpReqsData()[key] || isEditing())) {
|
|
101
|
-
const evaluatedUrl = evalExpression(url);
|
|
102
|
-
handleRequest({
|
|
103
|
-
url: evaluatedUrl,
|
|
104
|
-
key
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function emitStateUpdate() {
|
|
111
|
-
window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
|
|
112
|
-
detail: {
|
|
113
|
-
state: contentState(),
|
|
114
|
-
ref: {
|
|
115
|
-
name: model
|
|
116
63
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return mergedContent;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
$: contentState = () => {
|
|
132
|
-
return { ...content?.data?.state,
|
|
133
|
-
...data,
|
|
134
|
-
...overrideState
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
$: context = () => {
|
|
139
|
-
return {};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
$: httpReqsData = () => {
|
|
143
|
-
return {};
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
setContext(BuilderContext.key, { get content() {
|
|
148
|
-
return useContent();
|
|
149
|
-
}, get state() {
|
|
150
|
-
return contentState();
|
|
151
|
-
}, get context() {
|
|
152
|
-
return context();
|
|
153
|
-
}, get apiKey() {
|
|
154
|
-
return apiKey;
|
|
155
|
-
},});
|
|
156
|
-
let overrideContent = null;
|
|
157
|
-
let update = 0;
|
|
158
|
-
let overrideState = {};
|
|
159
|
-
|
|
160
|
-
onMount(() => { if (isBrowser()) {
|
|
161
|
-
if (isEditing()) {
|
|
162
|
-
window.addEventListener('message', processMessage);
|
|
163
|
-
window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (useContent()) {
|
|
167
|
-
track('impression', {
|
|
168
|
-
contentId: useContent().id
|
|
169
|
-
});
|
|
170
|
-
} // override normal content in preview mode
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (isPreviewing()) {
|
|
174
|
-
if (model && previewingModelName() === model) {
|
|
175
|
-
const currentUrl = new URL(location.href);
|
|
176
|
-
const previewApiKey = currentUrl.searchParams.get('apiKey');
|
|
177
|
-
|
|
178
|
-
if (previewApiKey) {
|
|
179
|
-
getContent({
|
|
180
|
-
model: model,
|
|
181
|
-
apiKey: previewApiKey,
|
|
182
|
-
options: getBuilderSearchParams(convertSearchParamsToQueryObject(currentUrl.searchParams))
|
|
183
|
-
}).then(content => {
|
|
184
|
-
if (content) {
|
|
185
|
-
overrideContent = content;
|
|
186
|
-
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const evaluateJsCode = function evaluateJsCode() {
|
|
67
|
+
// run any dynamic JS code attached to content
|
|
68
|
+
const jsCode = useContent?.()?.data?.jsCode;
|
|
69
|
+
|
|
70
|
+
if (jsCode) {
|
|
71
|
+
evaluate({
|
|
72
|
+
code: jsCode,
|
|
73
|
+
context: contextContext(),
|
|
74
|
+
state: contentState(),
|
|
187
75
|
});
|
|
188
76
|
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
77
|
+
};
|
|
191
78
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
};
|
|
88
|
+
|
|
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
|
+
};
|
|
196
97
|
|
|
197
|
-
|
|
98
|
+
fetchAndSetState();
|
|
99
|
+
};
|
|
198
100
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
204
113
|
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
$: useContent = () => {
|
|
129
|
+
const mergedContent = {
|
|
130
|
+
...content,
|
|
131
|
+
...overrideContent,
|
|
132
|
+
data: { ...content?.data, ...data, ...overrideContent?.data },
|
|
133
|
+
};
|
|
134
|
+
return mergedContent;
|
|
135
|
+
};
|
|
207
136
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
})}" data-builder-content-id={useContent?.()?.id} >
|
|
212
|
-
|
|
137
|
+
$: contentState = () => {
|
|
138
|
+
return { ...content?.data?.state, ...data, ...overrideState };
|
|
139
|
+
};
|
|
213
140
|
|
|
214
|
-
|
|
215
|
-
|
|
141
|
+
$: contextContext = () => {
|
|
142
|
+
return context || {};
|
|
143
|
+
};
|
|
216
144
|
|
|
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
|
+
};
|
|
217
161
|
|
|
218
|
-
{
|
|
162
|
+
$: httpReqsData = () => {
|
|
163
|
+
return {};
|
|
164
|
+
};
|
|
219
165
|
|
|
220
|
-
|
|
221
|
-
|
|
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
|
+
},
|
|
182
|
+
});
|
|
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
|
+
}
|
|
222
202
|
|
|
223
|
-
|
|
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
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
224
229
|
|
|
225
|
-
|
|
230
|
+
evaluateJsCode();
|
|
231
|
+
runHttpRequests();
|
|
232
|
+
emitStateUpdate();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
226
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>
|
|
227
259
|
|
|
228
|
-
{
|
|
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>
|
|
278
|
+
{/if}
|
|
@@ -1,49 +1,21 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { TARGET } from '../constants/target';
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
7
3
|
|
|
8
|
-
|
|
4
|
+
export let styles;
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export let styles;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
$: injectedStyleScript = () => {
|
|
17
|
-
return `<${tagName()}>${styles}</${tagName()}>`;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
$: tagName = () => {
|
|
21
|
-
// NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
22
|
-
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
23
|
-
return 'sty' + 'le';
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{#if TARGET === 'svelte' }
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{@html injectedStyleScript()}
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
$: injectedStyleScript = () => {
|
|
7
|
+
return `<${tagName()}>${styles}</${tagName()}>`;
|
|
8
|
+
};
|
|
44
9
|
|
|
10
|
+
$: tagName = () => {
|
|
11
|
+
// NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
12
|
+
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
13
|
+
return "sty" + "le";
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
45
16
|
|
|
17
|
+
{#if TARGET === "svelte"}
|
|
18
|
+
{@html injectedStyleScript()}
|
|
46
19
|
{:else}
|
|
47
|
-
<svelte:component
|
|
48
|
-
|
|
49
|
-
{/if}
|
|
20
|
+
<svelte:component this={tagName()}>{styles}</svelte:component>
|
|
21
|
+
{/if}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.svelte";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
|
|
19
|
+
import { default as Columns } from "../blocks/columns/columns.svelte";
|
|
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.svelte";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
|
|
24
|
+
import { default as Image } from "../blocks/image/image.svelte";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
|
|
26
|
+
import { default as Section } from "../blocks/section/section.svelte";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
|
|
28
|
+
import { default as Symbol } from "../blocks/symbol/symbol.svelte";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
|
|
30
|
+
import { default as Text } from "../blocks/text/text.svelte";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
|
|
32
|
+
import { default as Video } from "../blocks/video/video.svelte";
|
|
33
|
+
import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info";
|
|
34
|
+
import { default as embed } from "../blocks/embed/embed.svelte";
|
|
35
|
+
const getDefaultRegisteredComponents = () => [
|
|
36
|
+
__spreadValues({ component: Columns }, columnsComponentInfo),
|
|
37
|
+
__spreadValues({ component: Image }, imageComponentInfo),
|
|
38
|
+
__spreadValues({ component: Text }, textComponentInfo),
|
|
39
|
+
__spreadValues({ component: Video }, videoComponentInfo),
|
|
40
|
+
__spreadValues({ component: Symbol }, symbolComponentInfo),
|
|
41
|
+
__spreadValues({ component: Button }, buttonComponentInfo),
|
|
42
|
+
__spreadValues({ component: Section }, sectionComponentInfo),
|
|
43
|
+
__spreadValues({ component: Fragment }, fragmentComponentInfo),
|
|
44
|
+
__spreadValues({ component: embed }, embedComponentInfo)
|
|
45
|
+
];
|
|
46
|
+
export {
|
|
47
|
+
getDefaultRegisteredComponents
|
|
48
|
+
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const sizes = {
|
|
3
|
-
xsmall: {
|
|
4
|
-
min: 0,
|
|
5
|
-
default: 0,
|
|
6
|
-
max: 0
|
|
7
|
-
},
|
|
1
|
+
const SIZES = {
|
|
8
2
|
small: {
|
|
9
3
|
min: 320,
|
|
10
4
|
default: 321,
|
|
@@ -19,21 +13,9 @@ const sizes = {
|
|
|
19
13
|
min: 990,
|
|
20
14
|
default: 991,
|
|
21
15
|
max: 1200
|
|
22
|
-
},
|
|
23
|
-
getWidthForSize(size) {
|
|
24
|
-
return this[size].default;
|
|
25
|
-
},
|
|
26
|
-
getSizeForWidth(width) {
|
|
27
|
-
for (const size of sizeNames) {
|
|
28
|
-
const value = this[size];
|
|
29
|
-
if (width <= value.max) {
|
|
30
|
-
return size;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return "large";
|
|
34
16
|
}
|
|
35
17
|
};
|
|
18
|
+
const getMaxWidthQueryForSize = (size) => `@media (max-width: ${SIZES[size].max}px)`;
|
|
36
19
|
export {
|
|
37
|
-
|
|
38
|
-
sizes
|
|
20
|
+
getMaxWidthQueryForSize
|
|
39
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { evaluate } from "./evaluate";
|
|
2
|
-
import { getEventHandlerName } from "./event-handler-name";
|
|
1
|
+
import { evaluate } from "./evaluate.js";
|
|
2
|
+
import { getEventHandlerName } from "./event-handler-name.js";
|
|
3
3
|
function getBlockActions(options) {
|
|
4
4
|
var _a;
|
|
5
5
|
const obj = {};
|