@builder.io/sdk-svelte 0.1.2 → 0.1.3-0
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/--package.json +3 -3
- package/package/CHANGELOG.md +5 -0
- package/package/blocks/BaseText.svelte +1 -1
- package/package/blocks/button/button.svelte +1 -1
- package/package/blocks/columns/columns.svelte +3 -3
- package/package/blocks/custom-code/custom-code.svelte +1 -1
- package/package/blocks/embed/embed.svelte +2 -3
- package/package/blocks/form/form.svelte +1 -1
- package/package/blocks/fragment/fragment.svelte +1 -1
- package/package/blocks/image/image.svelte +1 -2
- package/package/blocks/img/img.svelte +1 -1
- package/package/blocks/input/input.svelte +1 -1
- package/package/blocks/raw-text/raw-text.svelte +1 -1
- package/package/blocks/section/section.svelte +1 -1
- package/package/blocks/select/select.svelte +1 -1
- package/package/blocks/submit-button/submit-button.svelte +1 -1
- package/package/blocks/symbol/symbol.svelte +4 -2
- package/package/blocks/text/text.svelte +1 -1
- package/package/blocks/textarea/textarea.svelte +1 -1
- package/package/blocks/video/video.svelte +1 -1
- package/package/components/render-block/block-styles.svelte +1 -1
- package/package/components/render-block/render-block.helpers.d.ts +11 -0
- package/package/components/render-block/render-block.helpers.js +58 -0
- package/package/components/render-block/render-block.svelte +33 -109
- package/package/components/render-block/render-component.svelte +1 -1
- package/package/components/render-block/render-repeated-block.svelte +7 -19
- package/package/components/render-blocks.svelte +1 -1
- package/package/components/render-content/builder-editing.svelte +1 -1
- package/package/components/render-content/components/render-styles.svelte +3 -3
- package/package/components/render-content/render-content.svelte +52 -53
- package/package/components/render-inlined-styles.svelte +1 -1
- package/package/functions/track/helpers.d.ts +5 -0
- package/package/functions/track/helpers.js +56 -0
- package/package/functions/{track.d.ts → track/index.d.ts} +5 -10
- package/package/functions/{track.js → track/index.js} +11 -6
- package/package/index.d.ts +1 -1
- package/package/index.js +1 -1
- package/package.json +1 -1
- package/src/blocks/BaseText.svelte +2 -2
- package/src/blocks/button/button.svelte +1 -6
- package/src/blocks/columns/columns.svelte +3 -3
- package/src/blocks/custom-code/custom-code.svelte +1 -1
- package/src/blocks/embed/embed.svelte +1 -3
- package/src/blocks/form/form.svelte +2 -7
- package/src/blocks/fragment/fragment.svelte +1 -1
- package/src/blocks/image/image.svelte +1 -2
- package/src/blocks/img/img.svelte +1 -6
- package/src/blocks/input/input.svelte +1 -6
- package/src/blocks/raw-text/raw-text.svelte +1 -1
- package/src/blocks/section/section.svelte +1 -6
- package/src/blocks/select/select.svelte +1 -6
- package/src/blocks/submit-button/submit-button.svelte +1 -6
- package/src/blocks/symbol/symbol.svelte +5 -8
- package/src/blocks/text/text.svelte +1 -1
- package/src/blocks/textarea/textarea.svelte +1 -6
- package/src/blocks/video/video.svelte +1 -6
- package/src/components/render-block/block-styles.svelte +1 -1
- package/src/components/render-block/render-block.helpers.ts +85 -0
- package/src/components/render-block/render-block.svelte +41 -118
- package/src/components/render-block/render-component.svelte +1 -1
- package/src/components/render-block/render-repeated-block.svelte +8 -20
- package/src/components/render-blocks.svelte +2 -2
- package/src/components/render-content/builder-editing.svelte +1 -1
- package/src/components/render-content/components/render-styles.svelte +5 -3
- package/src/components/render-content/render-content.svelte +58 -64
- package/src/components/render-inlined-styles.svelte +1 -1
- package/src/functions/track/helpers.ts +67 -0
- package/src/functions/{track.ts → track/index.ts} +16 -17
- package/src/index.ts +1 -1
- package/package/components/render-block/render-component-with-context.svelte +0 -32
- package/package/components/render-block/render-component-with-context.svelte.d.ts +0 -19
- package/src/components/render-block/render-component-with-context.svelte +0 -38
package/package/--package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-svelte",
|
|
3
3
|
"description": "Builder.io SDK for Svelte",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"package",
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"./components/render-block/block-styles.svelte": "./components/render-block/block-styles.svelte",
|
|
68
68
|
"./components/render-block/render-block.helpers": "./components/render-block/render-block.helpers.js",
|
|
69
69
|
"./components/render-block/render-block.svelte": "./components/render-block/render-block.svelte",
|
|
70
|
-
"./components/render-block/render-component-with-context.svelte": "./components/render-block/render-component-with-context.svelte",
|
|
71
70
|
"./components/render-block/render-component.svelte": "./components/render-block/render-component.svelte",
|
|
72
71
|
"./components/render-block/render-repeated-block.svelte": "./components/render-block/render-repeated-block.svelte",
|
|
73
72
|
"./components/render-block/types": "./components/render-block/types.js",
|
|
@@ -117,7 +116,8 @@
|
|
|
117
116
|
"./functions/set-editor-settings": "./functions/set-editor-settings.js",
|
|
118
117
|
"./functions/set.test": "./functions/set.test.js",
|
|
119
118
|
"./functions/set": "./functions/set.js",
|
|
120
|
-
"./functions/track": "./functions/track.js",
|
|
119
|
+
"./functions/track/helpers": "./functions/track/helpers.js",
|
|
120
|
+
"./functions/track": "./functions/track/index.js",
|
|
121
121
|
"./functions/transform-block-properties": "./functions/transform-block-properties.js",
|
|
122
122
|
"./functions/transform-block": "./functions/transform-block.js",
|
|
123
123
|
"./helpers/ab-tests": "./helpers/ab-tests.js",
|
package/package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
### 0.1.1
|
|
2
|
+
|
|
3
|
+
- Fix: respect when `canTrack` is set to `false`
|
|
4
|
+
- Fix: issues sending session and visitor IDs with tracking events
|
|
5
|
+
|
|
1
6
|
### 0.1.0
|
|
2
7
|
|
|
3
8
|
🧨 Breaking change: we no longer provide a `node-fetch` polyfill. See [the docs](./README.md#fetch) for more information.
|
|
@@ -114,10 +114,10 @@ $: columnsStyles = () => {
|
|
|
114
114
|
`;
|
|
115
115
|
};
|
|
116
116
|
$: reactNativeColumnsStyles = () => {
|
|
117
|
-
return columnStyleObjects.columns.small;
|
|
117
|
+
return this.columnStyleObjects.columns.small;
|
|
118
118
|
};
|
|
119
119
|
$: reactNativeColumnStyles = () => {
|
|
120
|
-
return columnStyleObjects.column.small;
|
|
120
|
+
return this.columnStyleObjects.column.small;
|
|
121
121
|
};
|
|
122
122
|
</script>
|
|
123
123
|
|
|
@@ -164,4 +164,4 @@ $: reactNativeColumnStyles = () => {
|
|
|
164
164
|
flex-direction: column;
|
|
165
165
|
align-items: stretch;
|
|
166
166
|
}
|
|
167
|
-
</style>
|
|
167
|
+
</style>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import "
|
|
4
|
-
import { isJsScript } from "./helpers.js";
|
|
3
|
+
<script>import { isJsScript } from "./helpers.js";
|
|
5
4
|
export let content;
|
|
6
5
|
function findAndRunScripts() {
|
|
7
6
|
if (!elem || !elem.getElementsByTagName)
|
|
@@ -40,4 +39,4 @@ function onUpdateFn_0() {
|
|
|
40
39
|
$: onUpdateFn_0(...[elem, ranInitFn]);
|
|
41
40
|
</script>
|
|
42
41
|
|
|
43
|
-
<div class="builder-embed" bind:this={elem}>{@html content}</div>
|
|
42
|
+
<div class="builder-embed" bind:this={elem}>{@html content}</div>
|
|
@@ -82,7 +82,6 @@ $: aspectRatioCss = () => {
|
|
|
82
82
|
srcset={srcSetToUse()}
|
|
83
83
|
{sizes}
|
|
84
84
|
/>
|
|
85
|
-
<source srcset={srcSetToUse()} />
|
|
86
85
|
</picture>
|
|
87
86
|
|
|
88
87
|
{#if aspectRatio && !(builderBlock?.children?.length && fitContent)}
|
|
@@ -126,4 +125,4 @@ $: aspectRatioCss = () => {
|
|
|
126
125
|
width: 100%;
|
|
127
126
|
height: 100%;
|
|
128
127
|
}
|
|
129
|
-
</style>
|
|
128
|
+
</style>
|
|
@@ -66,7 +66,9 @@ function onUpdateFn_0() {
|
|
|
66
66
|
if (symbolToUse &&
|
|
67
67
|
!symbolToUse.content &&
|
|
68
68
|
!fetchedContent &&
|
|
69
|
-
symbolToUse.model
|
|
69
|
+
symbolToUse.model &&
|
|
70
|
+
// This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
71
|
+
builderContext?.apiKey) {
|
|
70
72
|
getContent({
|
|
71
73
|
model: symbolToUse.model,
|
|
72
74
|
apiKey: builderContext.apiKey,
|
|
@@ -101,4 +103,4 @@ $: onUpdateFn_0(...[symbol, fetchedContent]);
|
|
|
101
103
|
model={symbol?.model}
|
|
102
104
|
content={contentToUse()}
|
|
103
105
|
/>
|
|
104
|
-
</div>
|
|
106
|
+
</div>
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
+
import type { BuilderBlock } from '../../types/builder-block';
|
|
3
|
+
import type { RepeatData } from './types';
|
|
1
4
|
export declare const isEmptyHtmlElement: (tagName: unknown) => boolean;
|
|
5
|
+
export declare const getComponent: ({ block, context, }: {
|
|
6
|
+
block: BuilderBlock;
|
|
7
|
+
context: BuilderContextInterface;
|
|
8
|
+
}) => import("../../context/types").RegisteredComponent | null | undefined;
|
|
9
|
+
export declare const getRepeatItemData: ({ block, context, }: {
|
|
10
|
+
block: BuilderBlock;
|
|
11
|
+
context: BuilderContextInterface;
|
|
12
|
+
}) => RepeatData[] | undefined;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { evaluate } from '../../functions/evaluate';
|
|
2
|
+
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
1
3
|
/**
|
|
2
4
|
* https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
|
3
5
|
*/
|
|
@@ -22,3 +24,59 @@ export const isEmptyHtmlElement = (tagName) => {
|
|
|
22
24
|
return (typeof tagName === 'string' &&
|
|
23
25
|
EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase()));
|
|
24
26
|
};
|
|
27
|
+
export const getComponent = ({ block, context, }) => {
|
|
28
|
+
const componentName = getProcessedBlock({
|
|
29
|
+
block: block,
|
|
30
|
+
state: context.state,
|
|
31
|
+
context: context.context,
|
|
32
|
+
shouldEvaluateBindings: false,
|
|
33
|
+
}).component?.name;
|
|
34
|
+
if (!componentName) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const ref = context.registeredComponents[componentName];
|
|
38
|
+
if (!ref) {
|
|
39
|
+
// TODO: Public doc page with more info about this message
|
|
40
|
+
console.warn(`
|
|
41
|
+
Could not find a registered component named "${componentName}".
|
|
42
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return ref;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export const getRepeatItemData = ({ block, context, }) => {
|
|
50
|
+
/**
|
|
51
|
+
* we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
|
|
52
|
+
* which will not work if there is a repeat.
|
|
53
|
+
*/
|
|
54
|
+
const { repeat, ...blockWithoutRepeat } = block;
|
|
55
|
+
if (!repeat?.collection) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const itemsArray = evaluate({
|
|
59
|
+
code: repeat.collection,
|
|
60
|
+
state: context.state,
|
|
61
|
+
context: context.context,
|
|
62
|
+
});
|
|
63
|
+
if (!Array.isArray(itemsArray)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const collectionName = repeat.collection.split('.').pop();
|
|
67
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + 'Item' : 'item');
|
|
68
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
69
|
+
context: {
|
|
70
|
+
...context,
|
|
71
|
+
state: {
|
|
72
|
+
...context.state,
|
|
73
|
+
$index: index,
|
|
74
|
+
$item: item,
|
|
75
|
+
[itemNameToUse]: item,
|
|
76
|
+
[`$${itemNameToUse}Index`]: index,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
block: blockWithoutRepeat,
|
|
80
|
+
}));
|
|
81
|
+
return repeatArray;
|
|
82
|
+
};
|
|
@@ -5,13 +5,11 @@ import { getBlockComponentOptions } from "../../functions/get-block-component-op
|
|
|
5
5
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
6
6
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
7
7
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import { evaluate } from "../../functions/evaluate.js";
|
|
9
8
|
import BlockStyles from "./block-styles.svelte";
|
|
10
|
-
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
9
|
+
import { getComponent, getRepeatItemData, isEmptyHtmlElement, } from "./render-block.helpers.js";
|
|
11
10
|
import RenderRepeatedBlock from "./render-repeated-block.svelte";
|
|
12
11
|
import { TARGET } from "../../constants/target.js";
|
|
13
12
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
14
|
-
import RenderComponentWithContext from "./render-component-with-context.svelte";
|
|
15
13
|
import RenderComponent from "./render-component.svelte";
|
|
16
14
|
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
17
15
|
const setAttrs = (node, attrs) => {
|
|
@@ -32,33 +30,11 @@ const setAttrs = (node, attrs) => {
|
|
|
32
30
|
};
|
|
33
31
|
export let block;
|
|
34
32
|
export let context;
|
|
35
|
-
$: component = () => {
|
|
36
|
-
const componentName = getProcessedBlock({
|
|
37
|
-
block: block,
|
|
38
|
-
state: context.state,
|
|
39
|
-
context: context.context,
|
|
40
|
-
shouldEvaluateBindings: false,
|
|
41
|
-
}).component?.name;
|
|
42
|
-
if (!componentName) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const ref = context.registeredComponents[componentName];
|
|
46
|
-
if (!ref) {
|
|
47
|
-
// TODO: Public doc page with more info about this message
|
|
48
|
-
console.warn(`
|
|
49
|
-
Could not find a registered component named "${componentName}".
|
|
50
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return ref;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
33
|
$: tag = () => {
|
|
58
34
|
return getBlockTag(useBlock());
|
|
59
35
|
};
|
|
60
36
|
$: useBlock = () => {
|
|
61
|
-
return repeatItemData
|
|
37
|
+
return repeatItemData
|
|
62
38
|
? block
|
|
63
39
|
: getProcessedBlock({
|
|
64
40
|
block: block,
|
|
@@ -89,20 +65,17 @@ $: attributes = () => {
|
|
|
89
65
|
: {}),
|
|
90
66
|
};
|
|
91
67
|
};
|
|
92
|
-
$: shouldWrap = () => {
|
|
93
|
-
return !component?.()?.noWrap;
|
|
94
|
-
};
|
|
95
68
|
$: renderComponentProps = () => {
|
|
96
69
|
return {
|
|
97
|
-
blockChildren:
|
|
98
|
-
componentRef: component?.
|
|
70
|
+
blockChildren: useBlock().children ?? [],
|
|
71
|
+
componentRef: component?.component,
|
|
99
72
|
componentOptions: {
|
|
100
73
|
...getBlockComponentOptions(useBlock()),
|
|
101
74
|
/**
|
|
102
75
|
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
103
76
|
* they are provided to the component itself directly.
|
|
104
77
|
*/
|
|
105
|
-
...(
|
|
78
|
+
...(!component?.noWrap
|
|
106
79
|
? {}
|
|
107
80
|
: {
|
|
108
81
|
attributes: {
|
|
@@ -115,13 +88,6 @@ $: renderComponentProps = () => {
|
|
|
115
88
|
context: childrenContext(),
|
|
116
89
|
};
|
|
117
90
|
};
|
|
118
|
-
$: useChildren = () => {
|
|
119
|
-
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
120
|
-
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
121
|
-
// but still receive and need to render children.
|
|
122
|
-
// return componentInfo?.canHaveChildren ? useBlock().children : [];
|
|
123
|
-
return useBlock().children ?? [];
|
|
124
|
-
};
|
|
125
91
|
$: childrenWithoutParentComponent = () => {
|
|
126
92
|
/**
|
|
127
93
|
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
@@ -129,95 +95,53 @@ $: childrenWithoutParentComponent = () => {
|
|
|
129
95
|
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
130
96
|
* blocks, and the children will be repeated within those blocks.
|
|
131
97
|
*/
|
|
132
|
-
const shouldRenderChildrenOutsideRef = !component?.
|
|
133
|
-
return shouldRenderChildrenOutsideRef ?
|
|
134
|
-
};
|
|
135
|
-
$: repeatItemData = () => {
|
|
136
|
-
/**
|
|
137
|
-
* we don't use `useBlock()` here because the processing done within its logic includes evaluating the block's bindings,
|
|
138
|
-
* which will not work if there is a repeat.
|
|
139
|
-
*/
|
|
140
|
-
const { repeat, ...blockWithoutRepeat } = block;
|
|
141
|
-
if (!repeat?.collection) {
|
|
142
|
-
return undefined;
|
|
143
|
-
}
|
|
144
|
-
const itemsArray = evaluate({
|
|
145
|
-
code: repeat.collection,
|
|
146
|
-
state: context.state,
|
|
147
|
-
context: context.context,
|
|
148
|
-
});
|
|
149
|
-
if (!Array.isArray(itemsArray)) {
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
153
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
154
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
155
|
-
context: {
|
|
156
|
-
...context,
|
|
157
|
-
state: {
|
|
158
|
-
...context.state,
|
|
159
|
-
$index: index,
|
|
160
|
-
$item: item,
|
|
161
|
-
[itemNameToUse]: item,
|
|
162
|
-
[`$${itemNameToUse}Index`]: index,
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
block: blockWithoutRepeat,
|
|
166
|
-
}));
|
|
167
|
-
return repeatArray;
|
|
168
|
-
};
|
|
169
|
-
$: inheritedTextStyles = () => {
|
|
170
|
-
if (TARGET !== "reactNative") {
|
|
171
|
-
return {};
|
|
172
|
-
}
|
|
173
|
-
const styles = getReactNativeBlockStyles({
|
|
174
|
-
block: useBlock(),
|
|
175
|
-
context: context,
|
|
176
|
-
blockStyles: attributes().style,
|
|
177
|
-
});
|
|
178
|
-
return extractTextStyles(styles);
|
|
98
|
+
const shouldRenderChildrenOutsideRef = !component?.component && !repeatItemData;
|
|
99
|
+
return shouldRenderChildrenOutsideRef ? useBlock().children ?? [] : [];
|
|
179
100
|
};
|
|
180
101
|
$: childrenContext = () => {
|
|
102
|
+
const getInheritedTextStyles = () => {
|
|
103
|
+
if (TARGET !== "reactNative") {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
return extractTextStyles(getReactNativeBlockStyles({
|
|
107
|
+
block: useBlock(),
|
|
108
|
+
context: context,
|
|
109
|
+
blockStyles: attributes().style,
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
181
112
|
return {
|
|
182
113
|
apiKey: context.apiKey,
|
|
183
114
|
state: context.state,
|
|
184
115
|
content: context.content,
|
|
185
116
|
context: context.context,
|
|
186
117
|
registeredComponents: context.registeredComponents,
|
|
187
|
-
inheritedStyles:
|
|
118
|
+
inheritedStyles: getInheritedTextStyles(),
|
|
188
119
|
};
|
|
189
120
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
else {
|
|
199
|
-
return RenderComponent;
|
|
200
|
-
}
|
|
201
|
-
};
|
|
121
|
+
let component = getComponent({
|
|
122
|
+
block: block,
|
|
123
|
+
context: context,
|
|
124
|
+
});
|
|
125
|
+
let repeatItemData = getRepeatItemData({
|
|
126
|
+
block: block,
|
|
127
|
+
context: context,
|
|
128
|
+
});
|
|
202
129
|
</script>
|
|
203
130
|
|
|
204
|
-
{#if
|
|
131
|
+
{#if !component?.noWrap}
|
|
205
132
|
{#if isEmptyHtmlElement(tag())}
|
|
206
133
|
<svelte:element this={tag()} {...attributes()} use:setAttrs={actions()} />
|
|
207
134
|
{/if}
|
|
208
135
|
|
|
209
|
-
{#if !isEmptyHtmlElement(tag()) && repeatItemData
|
|
210
|
-
{#each repeatItemData
|
|
136
|
+
{#if !isEmptyHtmlElement(tag()) && repeatItemData}
|
|
137
|
+
{#each repeatItemData as data, index (index)}
|
|
211
138
|
<RenderRepeatedBlock repeatContext={data.context} block={data.block} />
|
|
212
139
|
{/each}
|
|
213
140
|
{/if}
|
|
214
141
|
|
|
215
|
-
{#if !isEmptyHtmlElement(tag()) && !repeatItemData
|
|
142
|
+
{#if !isEmptyHtmlElement(tag()) && !repeatItemData}
|
|
216
143
|
<svelte:element this={tag()} {...attributes()} use:setAttrs={actions()}>
|
|
217
|
-
<
|
|
218
|
-
this={renderComponentTag()}
|
|
219
|
-
{...renderComponentProps()}
|
|
220
|
-
/>
|
|
144
|
+
<RenderComponent {...renderComponentProps()} />
|
|
221
145
|
|
|
222
146
|
{#each childrenWithoutParentComponent() as child ("render-block-" + child.id)}
|
|
223
147
|
<svelte:self block={child} context={childrenContext()} />
|
|
@@ -229,5 +153,5 @@ $: renderComponentTag = () => {
|
|
|
229
153
|
</svelte:element>
|
|
230
154
|
{/if}
|
|
231
155
|
{:else}
|
|
232
|
-
<
|
|
233
|
-
{/if}
|
|
156
|
+
<RenderComponent {...renderComponentProps()} />
|
|
157
|
+
{/if}
|
|
@@ -15,25 +15,13 @@ import RenderBlock from "./render-block.svelte";
|
|
|
15
15
|
export let block;
|
|
16
16
|
export let repeatContext;
|
|
17
17
|
setContext(BuilderContext.key, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
get context() {
|
|
25
|
-
return repeatContext.context;
|
|
26
|
-
},
|
|
27
|
-
get apiKey() {
|
|
28
|
-
return repeatContext.apiKey;
|
|
29
|
-
},
|
|
30
|
-
get registeredComponents() {
|
|
31
|
-
return repeatContext.registeredComponents;
|
|
32
|
-
},
|
|
33
|
-
get inheritedStyles() {
|
|
34
|
-
return repeatContext.inheritedStyles;
|
|
35
|
-
},
|
|
18
|
+
content: repeatContext.content,
|
|
19
|
+
state: repeatContext.state,
|
|
20
|
+
context: repeatContext.context,
|
|
21
|
+
apiKey: repeatContext.apiKey,
|
|
22
|
+
registeredComponents: repeatContext.registeredComponents,
|
|
23
|
+
inheritedStyles: repeatContext.inheritedStyles,
|
|
36
24
|
});
|
|
37
25
|
</script>
|
|
38
26
|
|
|
39
|
-
<RenderBlock {block} context={repeatContext} />
|
|
27
|
+
<RenderBlock {block} context={repeatContext} />
|
|
@@ -44,11 +44,11 @@ function getCssFromFont(font) {
|
|
|
44
44
|
}
|
|
45
45
|
function getFontCss({ customFonts }) {
|
|
46
46
|
// TODO: flag for this
|
|
47
|
-
// if (!builder.allowCustomFonts) {
|
|
47
|
+
// if (!this.builder.allowCustomFonts) {
|
|
48
48
|
// return '';
|
|
49
49
|
// }
|
|
50
50
|
// TODO: separate internal data from external
|
|
51
|
-
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
51
|
+
return (customFonts?.map((font) => this.getCssFromFont(font))?.join(" ") || "");
|
|
52
52
|
}
|
|
53
53
|
$: injectedStyles = () => {
|
|
54
54
|
return `
|
|
@@ -59,4 +59,4 @@ ${getFontCss({
|
|
|
59
59
|
};
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
|
-
<RenderInlinedStyles styles={injectedStyles()} />
|
|
62
|
+
<RenderInlinedStyles styles={injectedStyles()} />
|