@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
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
10
10
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
11
|
-
|
|
12
11
|
const filterAttrs = (attrs, filter) => {
|
|
13
12
|
const validAttr = {};
|
|
14
13
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -18,16 +17,12 @@
|
|
|
18
17
|
});
|
|
19
18
|
return validAttr;
|
|
20
19
|
};
|
|
21
|
-
|
|
22
20
|
const setAttrs = (node, attrs) => {
|
|
23
21
|
const attrKeys = Object.keys(attrs);
|
|
24
|
-
|
|
25
22
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
26
23
|
const teardown = (attr) =>
|
|
27
24
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
28
|
-
|
|
29
25
|
attrKeys.map(setup);
|
|
30
|
-
|
|
31
26
|
return {
|
|
32
27
|
update(attrs) {
|
|
33
28
|
const attrKeys = Object.keys(attrs);
|
|
@@ -50,4 +45,4 @@
|
|
|
50
45
|
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
51
46
|
>
|
|
52
47
|
{text}
|
|
53
|
-
</button>
|
|
48
|
+
</button>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
27
|
<script lang="ts">
|
|
28
|
-
import {
|
|
28
|
+
import { getContext } from "svelte";
|
|
29
29
|
|
|
30
30
|
import RenderContent from "../../components/render-content/render-content.svelte";
|
|
31
31
|
import BuilderContext from "../../context/builder.context.js";
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
|
|
35
35
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
36
36
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
37
|
-
|
|
38
37
|
const filterAttrs = (attrs, filter) => {
|
|
39
38
|
const validAttr = {};
|
|
40
39
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -44,16 +43,12 @@
|
|
|
44
43
|
});
|
|
45
44
|
return validAttr;
|
|
46
45
|
};
|
|
47
|
-
|
|
48
46
|
const setAttrs = (node, attrs) => {
|
|
49
47
|
const attrKeys = Object.keys(attrs);
|
|
50
|
-
|
|
51
48
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
52
49
|
const teardown = (attr) =>
|
|
53
50
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
54
|
-
|
|
55
51
|
attrKeys.map(setup);
|
|
56
|
-
|
|
57
52
|
return {
|
|
58
53
|
update(attrs) {
|
|
59
54
|
const attrKeys = Object.keys(attrs);
|
|
@@ -106,7 +101,9 @@
|
|
|
106
101
|
symbolToUse &&
|
|
107
102
|
!symbolToUse.content &&
|
|
108
103
|
!fetchedContent &&
|
|
109
|
-
symbolToUse.model
|
|
104
|
+
symbolToUse.model &&
|
|
105
|
+
// This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
106
|
+
builderContext?.apiKey
|
|
110
107
|
) {
|
|
111
108
|
getContent({
|
|
112
109
|
model: symbolToUse.model,
|
|
@@ -142,4 +139,4 @@
|
|
|
142
139
|
model={symbol?.model}
|
|
143
140
|
content={contentToUse()}
|
|
144
141
|
/>
|
|
145
|
-
</div>
|
|
142
|
+
</div>
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
<script lang="ts">
|
|
12
12
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
13
13
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
14
|
-
|
|
15
14
|
const filterAttrs = (attrs, filter) => {
|
|
16
15
|
const validAttr = {};
|
|
17
16
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -21,16 +20,12 @@
|
|
|
21
20
|
});
|
|
22
21
|
return validAttr;
|
|
23
22
|
};
|
|
24
|
-
|
|
25
23
|
const setAttrs = (node, attrs) => {
|
|
26
24
|
const attrKeys = Object.keys(attrs);
|
|
27
|
-
|
|
28
25
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
29
26
|
const teardown = (attr) =>
|
|
30
27
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
31
|
-
|
|
32
28
|
attrKeys.map(setup);
|
|
33
|
-
|
|
34
29
|
return {
|
|
35
30
|
update(attrs) {
|
|
36
31
|
const attrKeys = Object.keys(attrs);
|
|
@@ -57,4 +52,4 @@
|
|
|
57
52
|
{value}
|
|
58
53
|
{defaultValue}
|
|
59
54
|
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
60
|
-
/>
|
|
55
|
+
/>
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
<script lang="ts">
|
|
30
30
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
31
31
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
32
|
-
|
|
33
32
|
const filterAttrs = (attrs, filter) => {
|
|
34
33
|
const validAttr = {};
|
|
35
34
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -39,16 +38,12 @@
|
|
|
39
38
|
});
|
|
40
39
|
return validAttr;
|
|
41
40
|
};
|
|
42
|
-
|
|
43
41
|
const setAttrs = (node, attrs) => {
|
|
44
42
|
const attrKeys = Object.keys(attrs);
|
|
45
|
-
|
|
46
43
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
47
44
|
const teardown = (attr) =>
|
|
48
45
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
49
|
-
|
|
50
46
|
attrKeys.map(setup);
|
|
51
|
-
|
|
52
47
|
return {
|
|
53
48
|
update(attrs) {
|
|
54
49
|
const attrKeys = Object.keys(attrs);
|
|
@@ -134,4 +129,4 @@
|
|
|
134
129
|
src={video || "no-src"}
|
|
135
130
|
poster={posterImage}
|
|
136
131
|
use:setAttrs={filterAttrs(spreadProps(), isEvent)}
|
|
137
|
-
/>
|
|
132
|
+
/>
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
+
import { evaluate } from '../../functions/evaluate';
|
|
3
|
+
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
4
|
+
import type { BuilderBlock } from '../../types/builder-block';
|
|
5
|
+
import type { RepeatData } from './types';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
|
3
9
|
*/
|
|
@@ -25,3 +31,82 @@ export const isEmptyHtmlElement = (tagName: unknown) => {
|
|
|
25
31
|
EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase())
|
|
26
32
|
);
|
|
27
33
|
};
|
|
34
|
+
|
|
35
|
+
export const getComponent = ({
|
|
36
|
+
block,
|
|
37
|
+
context,
|
|
38
|
+
}: {
|
|
39
|
+
block: BuilderBlock;
|
|
40
|
+
context: BuilderContextInterface;
|
|
41
|
+
}) => {
|
|
42
|
+
const componentName = getProcessedBlock({
|
|
43
|
+
block: block,
|
|
44
|
+
state: context.state,
|
|
45
|
+
context: context.context,
|
|
46
|
+
shouldEvaluateBindings: false,
|
|
47
|
+
}).component?.name;
|
|
48
|
+
|
|
49
|
+
if (!componentName) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ref = context.registeredComponents[componentName];
|
|
54
|
+
|
|
55
|
+
if (!ref) {
|
|
56
|
+
// TODO: Public doc page with more info about this message
|
|
57
|
+
console.warn(`
|
|
58
|
+
Could not find a registered component named "${componentName}".
|
|
59
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
60
|
+
return undefined;
|
|
61
|
+
} else {
|
|
62
|
+
return ref;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const getRepeatItemData = ({
|
|
67
|
+
block,
|
|
68
|
+
context,
|
|
69
|
+
}: {
|
|
70
|
+
block: BuilderBlock;
|
|
71
|
+
context: BuilderContextInterface;
|
|
72
|
+
}): RepeatData[] | undefined => {
|
|
73
|
+
/**
|
|
74
|
+
* we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
|
|
75
|
+
* which will not work if there is a repeat.
|
|
76
|
+
*/
|
|
77
|
+
const { repeat, ...blockWithoutRepeat } = block;
|
|
78
|
+
|
|
79
|
+
if (!repeat?.collection) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const itemsArray = evaluate({
|
|
84
|
+
code: repeat.collection,
|
|
85
|
+
state: context.state,
|
|
86
|
+
context: context.context,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (!Array.isArray(itemsArray)) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const collectionName = repeat.collection.split('.').pop();
|
|
94
|
+
const itemNameToUse =
|
|
95
|
+
repeat.itemName || (collectionName ? collectionName + 'Item' : 'item');
|
|
96
|
+
|
|
97
|
+
const repeatArray = itemsArray.map<RepeatData>((item, index) => ({
|
|
98
|
+
context: {
|
|
99
|
+
...context,
|
|
100
|
+
state: {
|
|
101
|
+
...context.state,
|
|
102
|
+
$index: index,
|
|
103
|
+
$item: item,
|
|
104
|
+
[itemNameToUse]: item,
|
|
105
|
+
[`$${itemNameToUse}Index`]: index,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
block: blockWithoutRepeat,
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
return repeatArray;
|
|
112
|
+
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
<script context="module" lang="ts">
|
|
2
|
-
import type {
|
|
3
|
-
BuilderContextInterface,
|
|
4
|
-
RegisteredComponent,
|
|
5
|
-
} from "../../context/types.js";
|
|
2
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
6
3
|
|
|
7
4
|
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
8
5
|
|
|
9
|
-
import type { Nullable } from "../../types/typescript.js";
|
|
10
|
-
|
|
11
6
|
import type { RenderComponentProps } from "./render-component";
|
|
12
7
|
|
|
13
|
-
import type { RepeatData } from "./types.js";
|
|
14
|
-
|
|
15
8
|
export type RenderBlockProps = {
|
|
16
9
|
block: BuilderBlock;
|
|
17
10
|
context: BuilderContextInterface;
|
|
@@ -24,25 +17,24 @@
|
|
|
24
17
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
25
18
|
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
26
19
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
27
|
-
import { evaluate } from "../../functions/evaluate.js";
|
|
28
20
|
import BlockStyles from "./block-styles.svelte";
|
|
29
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
getComponent,
|
|
23
|
+
getRepeatItemData,
|
|
24
|
+
isEmptyHtmlElement,
|
|
25
|
+
} from "./render-block.helpers.js";
|
|
30
26
|
import RenderRepeatedBlock from "./render-repeated-block.svelte";
|
|
31
27
|
import { TARGET } from "../../constants/target.js";
|
|
32
28
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
33
|
-
import RenderComponentWithContext from "./render-component-with-context.svelte";
|
|
34
29
|
import RenderComponent from "./render-component.svelte";
|
|
35
30
|
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
36
31
|
|
|
37
32
|
const setAttrs = (node, attrs) => {
|
|
38
33
|
const attrKeys = Object.keys(attrs);
|
|
39
|
-
|
|
40
34
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
41
35
|
const teardown = (attr) =>
|
|
42
36
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
43
|
-
|
|
44
37
|
attrKeys.map(setup);
|
|
45
|
-
|
|
46
38
|
return {
|
|
47
39
|
update(attrs) {
|
|
48
40
|
const attrKeys = Object.keys(attrs);
|
|
@@ -58,32 +50,11 @@
|
|
|
58
50
|
export let block: RenderBlockProps["block"];
|
|
59
51
|
export let context: RenderBlockProps["context"];
|
|
60
52
|
|
|
61
|
-
$: component = () => {
|
|
62
|
-
const componentName = getProcessedBlock({
|
|
63
|
-
block: block,
|
|
64
|
-
state: context.state,
|
|
65
|
-
context: context.context,
|
|
66
|
-
shouldEvaluateBindings: false,
|
|
67
|
-
}).component?.name;
|
|
68
|
-
if (!componentName) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const ref = context.registeredComponents[componentName];
|
|
72
|
-
if (!ref) {
|
|
73
|
-
// TODO: Public doc page with more info about this message
|
|
74
|
-
console.warn(`
|
|
75
|
-
Could not find a registered component named "${componentName}".
|
|
76
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
77
|
-
return undefined;
|
|
78
|
-
} else {
|
|
79
|
-
return ref;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
53
|
$: tag = () => {
|
|
83
54
|
return getBlockTag(useBlock());
|
|
84
55
|
};
|
|
85
56
|
$: useBlock = () => {
|
|
86
|
-
return repeatItemData
|
|
57
|
+
return repeatItemData
|
|
87
58
|
? block
|
|
88
59
|
: getProcessedBlock({
|
|
89
60
|
block: block,
|
|
@@ -114,20 +85,17 @@
|
|
|
114
85
|
: {}),
|
|
115
86
|
};
|
|
116
87
|
};
|
|
117
|
-
$: shouldWrap = () => {
|
|
118
|
-
return !component?.()?.noWrap;
|
|
119
|
-
};
|
|
120
88
|
$: renderComponentProps = () => {
|
|
121
89
|
return {
|
|
122
|
-
blockChildren:
|
|
123
|
-
componentRef: component?.
|
|
90
|
+
blockChildren: useBlock().children ?? [],
|
|
91
|
+
componentRef: component?.component,
|
|
124
92
|
componentOptions: {
|
|
125
93
|
...getBlockComponentOptions(useBlock()),
|
|
126
94
|
/**
|
|
127
95
|
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
128
96
|
* they are provided to the component itself directly.
|
|
129
97
|
*/
|
|
130
|
-
...(
|
|
98
|
+
...(!component?.noWrap
|
|
131
99
|
? {}
|
|
132
100
|
: {
|
|
133
101
|
attributes: {
|
|
@@ -140,13 +108,6 @@
|
|
|
140
108
|
context: childrenContext(),
|
|
141
109
|
};
|
|
142
110
|
};
|
|
143
|
-
$: useChildren = () => {
|
|
144
|
-
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
145
|
-
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
146
|
-
// but still receive and need to render children.
|
|
147
|
-
// return componentInfo?.canHaveChildren ? useBlock().children : [];
|
|
148
|
-
return useBlock().children ?? [];
|
|
149
|
-
};
|
|
150
111
|
$: childrenWithoutParentComponent = () => {
|
|
151
112
|
/**
|
|
152
113
|
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
@@ -155,94 +116,56 @@
|
|
|
155
116
|
* blocks, and the children will be repeated within those blocks.
|
|
156
117
|
*/
|
|
157
118
|
const shouldRenderChildrenOutsideRef =
|
|
158
|
-
!component?.
|
|
159
|
-
return shouldRenderChildrenOutsideRef ?
|
|
160
|
-
};
|
|
161
|
-
$: repeatItemData = () => {
|
|
162
|
-
/**
|
|
163
|
-
* we don't use `useBlock()` here because the processing done within its logic includes evaluating the block's bindings,
|
|
164
|
-
* which will not work if there is a repeat.
|
|
165
|
-
*/
|
|
166
|
-
const { repeat, ...blockWithoutRepeat } = block;
|
|
167
|
-
if (!repeat?.collection) {
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
170
|
-
const itemsArray = evaluate({
|
|
171
|
-
code: repeat.collection,
|
|
172
|
-
state: context.state,
|
|
173
|
-
context: context.context,
|
|
174
|
-
});
|
|
175
|
-
if (!Array.isArray(itemsArray)) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
179
|
-
const itemNameToUse =
|
|
180
|
-
repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
181
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
182
|
-
context: {
|
|
183
|
-
...context,
|
|
184
|
-
state: {
|
|
185
|
-
...context.state,
|
|
186
|
-
$index: index,
|
|
187
|
-
$item: item,
|
|
188
|
-
[itemNameToUse]: item,
|
|
189
|
-
[`$${itemNameToUse}Index`]: index,
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
block: blockWithoutRepeat,
|
|
193
|
-
}));
|
|
194
|
-
return repeatArray;
|
|
195
|
-
};
|
|
196
|
-
$: inheritedTextStyles = () => {
|
|
197
|
-
if (TARGET !== "reactNative") {
|
|
198
|
-
return {};
|
|
199
|
-
}
|
|
200
|
-
const styles = getReactNativeBlockStyles({
|
|
201
|
-
block: useBlock(),
|
|
202
|
-
context: context,
|
|
203
|
-
blockStyles: attributes().style,
|
|
204
|
-
});
|
|
205
|
-
return extractTextStyles(styles);
|
|
119
|
+
!component?.component && !repeatItemData;
|
|
120
|
+
return shouldRenderChildrenOutsideRef ? useBlock().children ?? [] : [];
|
|
206
121
|
};
|
|
207
122
|
$: childrenContext = () => {
|
|
123
|
+
const getInheritedTextStyles = () => {
|
|
124
|
+
if (TARGET !== "reactNative") {
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
return extractTextStyles(
|
|
128
|
+
getReactNativeBlockStyles({
|
|
129
|
+
block: useBlock(),
|
|
130
|
+
context: context,
|
|
131
|
+
blockStyles: attributes().style,
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
};
|
|
208
135
|
return {
|
|
209
136
|
apiKey: context.apiKey,
|
|
210
137
|
state: context.state,
|
|
211
138
|
content: context.content,
|
|
212
139
|
context: context.context,
|
|
213
140
|
registeredComponents: context.registeredComponents,
|
|
214
|
-
inheritedStyles:
|
|
141
|
+
inheritedStyles: getInheritedTextStyles(),
|
|
215
142
|
};
|
|
216
143
|
};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
};
|
|
144
|
+
|
|
145
|
+
let component = getComponent({
|
|
146
|
+
block: block,
|
|
147
|
+
context: context,
|
|
148
|
+
});
|
|
149
|
+
let repeatItemData = getRepeatItemData({
|
|
150
|
+
block: block,
|
|
151
|
+
context: context,
|
|
152
|
+
});
|
|
227
153
|
</script>
|
|
228
154
|
|
|
229
|
-
{#if
|
|
155
|
+
{#if !component?.noWrap}
|
|
230
156
|
{#if isEmptyHtmlElement(tag())}
|
|
231
157
|
<svelte:element this={tag()} {...attributes()} use:setAttrs={actions()} />
|
|
232
158
|
{/if}
|
|
233
159
|
|
|
234
|
-
{#if !isEmptyHtmlElement(tag()) && repeatItemData
|
|
235
|
-
{#each repeatItemData
|
|
160
|
+
{#if !isEmptyHtmlElement(tag()) && repeatItemData}
|
|
161
|
+
{#each repeatItemData as data, index (index)}
|
|
236
162
|
<RenderRepeatedBlock repeatContext={data.context} block={data.block} />
|
|
237
163
|
{/each}
|
|
238
164
|
{/if}
|
|
239
165
|
|
|
240
|
-
{#if !isEmptyHtmlElement(tag()) && !repeatItemData
|
|
166
|
+
{#if !isEmptyHtmlElement(tag()) && !repeatItemData}
|
|
241
167
|
<svelte:element this={tag()} {...attributes()} use:setAttrs={actions()}>
|
|
242
|
-
<
|
|
243
|
-
this={renderComponentTag()}
|
|
244
|
-
{...renderComponentProps()}
|
|
245
|
-
/>
|
|
168
|
+
<RenderComponent {...renderComponentProps()} />
|
|
246
169
|
|
|
247
170
|
{#each childrenWithoutParentComponent() as child ("render-block-" + child.id)}
|
|
248
171
|
<svelte:self block={child} context={childrenContext()} />
|
|
@@ -254,5 +177,5 @@
|
|
|
254
177
|
</svelte:element>
|
|
255
178
|
{/if}
|
|
256
179
|
{:else}
|
|
257
|
-
<
|
|
258
|
-
{/if}
|
|
180
|
+
<RenderComponent {...renderComponentProps()} />
|
|
181
|
+
{/if}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<script lang="ts">
|
|
23
|
-
import {
|
|
23
|
+
import { setContext } from "svelte";
|
|
24
24
|
|
|
25
25
|
import BuilderContext from "../../context/builder.context.js";
|
|
26
26
|
import RenderBlock from "./render-block.svelte";
|
|
@@ -29,25 +29,13 @@
|
|
|
29
29
|
export let repeatContext: Props["repeatContext"];
|
|
30
30
|
|
|
31
31
|
setContext(BuilderContext.key, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
get context() {
|
|
39
|
-
return repeatContext.context;
|
|
40
|
-
},
|
|
41
|
-
get apiKey() {
|
|
42
|
-
return repeatContext.apiKey;
|
|
43
|
-
},
|
|
44
|
-
get registeredComponents() {
|
|
45
|
-
return repeatContext.registeredComponents;
|
|
46
|
-
},
|
|
47
|
-
get inheritedStyles() {
|
|
48
|
-
return repeatContext.inheritedStyles;
|
|
49
|
-
},
|
|
32
|
+
content: repeatContext.content,
|
|
33
|
+
state: repeatContext.state,
|
|
34
|
+
context: repeatContext.context,
|
|
35
|
+
apiKey: repeatContext.apiKey,
|
|
36
|
+
registeredComponents: repeatContext.registeredComponents,
|
|
37
|
+
inheritedStyles: repeatContext.inheritedStyles,
|
|
50
38
|
});
|
|
51
39
|
</script>
|
|
52
40
|
|
|
53
|
-
<RenderBlock {block} context={repeatContext} />
|
|
41
|
+
<RenderBlock {block} context={repeatContext} />
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<script lang="ts">
|
|
13
|
-
import { getContext
|
|
13
|
+
import { getContext } from "svelte";
|
|
14
14
|
|
|
15
15
|
import BuilderContext from "../context/builder.context.js";
|
|
16
16
|
import { isEditing } from "../functions/is-editing.js";
|
|
@@ -101,4 +101,4 @@
|
|
|
101
101
|
flex-direction: column;
|
|
102
102
|
align-items: stretch;
|
|
103
103
|
}
|
|
104
|
-
</style>
|
|
104
|
+
</style>
|
|
@@ -62,11 +62,13 @@
|
|
|
62
62
|
}
|
|
63
63
|
function getFontCss({ customFonts }) {
|
|
64
64
|
// TODO: flag for this
|
|
65
|
-
// if (!builder.allowCustomFonts) {
|
|
65
|
+
// if (!this.builder.allowCustomFonts) {
|
|
66
66
|
// return '';
|
|
67
67
|
// }
|
|
68
68
|
// TODO: separate internal data from external
|
|
69
|
-
return
|
|
69
|
+
return (
|
|
70
|
+
customFonts?.map((font) => this.getCssFromFont(font))?.join(" ") || ""
|
|
71
|
+
);
|
|
70
72
|
}
|
|
71
73
|
$: injectedStyles = () => {
|
|
72
74
|
return `
|
|
@@ -77,4 +79,4 @@ ${getFontCss({
|
|
|
77
79
|
};
|
|
78
80
|
</script>
|
|
79
81
|
|
|
80
|
-
<RenderInlinedStyles styles={injectedStyles()} />
|
|
82
|
+
<RenderInlinedStyles styles={injectedStyles()} />
|