@builder.io/sdk-svelte 0.0.1-30 → 0.0.1-33
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 +14 -5
- package/src/blocks/columns/columns.svelte +29 -6
- package/src/blocks/columns/component-info.js +3 -2
- package/src/blocks/custom-code/custom-code.svelte +11 -4
- package/src/blocks/embed/component-info.js +3 -2
- package/src/blocks/embed/embed.svelte +10 -4
- package/src/blocks/form/form.svelte +87 -40
- package/src/blocks/fragment/fragment.svelte +9 -1
- package/src/blocks/image/component-info.js +3 -2
- package/src/blocks/image/image.svelte +36 -15
- package/src/blocks/img/img.svelte +29 -7
- package/src/blocks/input/input.svelte +20 -8
- package/src/blocks/raw-text/raw-text.svelte +10 -3
- package/src/blocks/section/section.svelte +12 -3
- package/src/blocks/select/select.svelte +20 -7
- package/src/blocks/submit-button/submit-button.svelte +10 -3
- package/src/blocks/symbol/symbol.svelte +24 -4
- package/src/blocks/text/text.svelte +8 -2
- package/src/blocks/textarea/textarea.svelte +16 -6
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/video.svelte +39 -11
- package/src/components/render-block/block-styles.svelte +15 -12
- package/src/components/render-block/render-block.svelte +29 -25
- package/src/components/render-block/render-component.svelte +18 -8
- package/src/components/render-block/render-repeated-block.svelte +23 -5
- package/src/components/render-blocks.svelte +21 -8
- package/src/components/render-content/components/render-styles.svelte +19 -3
- package/src/components/render-content/render-content.svelte +82 -32
- package/src/components/render-inlined-styles.svelte +8 -2
- package/src/constants/builder-registered-components.js +12 -9
- package/src/functions/get-builder-search-params/index.js +1 -1
- package/src/functions/get-content/index.js +1 -1
- package/src/functions/get-fetch.js +2 -2
- package/src/functions/get-processed-block.js +10 -6
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/track.js +106 -13
- package/src/helpers/cookie.js +59 -0
- package/src/helpers/css.js +1 -1
- package/src/helpers/localStorage.js +34 -0
- package/src/helpers/nullable.js +4 -0
- package/src/helpers/sessionId.js +26 -0
- package/src/helpers/time.js +5 -0
- package/src/helpers/url.js +10 -0
- package/src/helpers/url.test.js +15 -0
- package/src/helpers/uuid.js +13 -0
- package/src/helpers/visitorId.js +33 -0
- package/src/scripts/init-editing.js +4 -5
- package/src/types/can-track.js +0 -0
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface TextareaProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
name?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
export let attributes: TextareaProps["attributes"];
|
|
13
|
+
export let placeholder: TextareaProps["placeholder"];
|
|
14
|
+
export let name: TextareaProps["name"];
|
|
15
|
+
export let value: TextareaProps["value"];
|
|
16
|
+
export let defaultValue: TextareaProps["defaultValue"];
|
|
7
17
|
</script>
|
|
8
18
|
|
|
9
19
|
<textarea {...attributes} {placeholder} {name} {value} {defaultValue} />
|
|
@@ -1,14 +1,42 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface VideoProps {
|
|
3
|
+
attributes?: any;
|
|
4
|
+
video?: string;
|
|
5
|
+
autoPlay?: boolean;
|
|
6
|
+
controls?: boolean;
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
loop?: boolean;
|
|
9
|
+
playsInline?: boolean;
|
|
10
|
+
aspectRatio?: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
fit?: "contain" | "cover" | "fill";
|
|
14
|
+
position?:
|
|
15
|
+
| "center"
|
|
16
|
+
| "top"
|
|
17
|
+
| "left"
|
|
18
|
+
| "right"
|
|
19
|
+
| "bottom"
|
|
20
|
+
| "top left"
|
|
21
|
+
| "top right"
|
|
22
|
+
| "bottom left"
|
|
23
|
+
| "bottom right";
|
|
24
|
+
posterImage?: string;
|
|
25
|
+
lazyLoad?: boolean;
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
export let autoPlay: VideoProps["autoPlay"];
|
|
31
|
+
export let muted: VideoProps["muted"];
|
|
32
|
+
export let controls: VideoProps["controls"];
|
|
33
|
+
export let loop: VideoProps["loop"];
|
|
34
|
+
export let playsInline: VideoProps["playsInline"];
|
|
35
|
+
export let attributes: VideoProps["attributes"];
|
|
36
|
+
export let fit: VideoProps["fit"];
|
|
37
|
+
export let position: VideoProps["position"];
|
|
38
|
+
export let video: VideoProps["video"];
|
|
39
|
+
export let posterImage: VideoProps["posterImage"];
|
|
12
40
|
|
|
13
41
|
function mitosis_styling(node, vars) {
|
|
14
42
|
Object.entries(vars).forEach(([p, v]) => {
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type BlockStylesProps = {
|
|
3
|
+
block: BuilderBlock;
|
|
4
|
+
context: BuilderContextInterface;
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
2
10
|
import { TARGET } from "../../constants/target.js";
|
|
3
|
-
import BuilderContext from "../../context/builder.context";
|
|
4
11
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
5
|
-
import RenderInlinedStyles from "../render-inlined-styles.svelte";
|
|
6
12
|
import { convertStyleMaptoCSS } from "../../helpers/css.js";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import { getContext, setContext } from "svelte";
|
|
13
|
+
import RenderInlinedStyles from "../render-inlined-styles.svelte";
|
|
10
14
|
|
|
11
|
-
export let block;
|
|
15
|
+
export let block: BlockStylesProps["block"];
|
|
16
|
+
export let context: BlockStylesProps["context"];
|
|
12
17
|
|
|
13
18
|
$: useBlock = () => {
|
|
14
19
|
return getProcessedBlock({
|
|
15
20
|
block: block,
|
|
16
|
-
state:
|
|
17
|
-
context:
|
|
18
|
-
|
|
21
|
+
state: context.state,
|
|
22
|
+
context: context.context,
|
|
23
|
+
shouldEvaluateBindings: true,
|
|
19
24
|
});
|
|
20
25
|
};
|
|
21
26
|
|
|
@@ -46,8 +51,6 @@
|
|
|
46
51
|
}
|
|
47
52
|
}`;
|
|
48
53
|
};
|
|
49
|
-
|
|
50
|
-
let builderContext = getContext(BuilderContext.key);
|
|
51
54
|
</script>
|
|
52
55
|
|
|
53
56
|
{#if TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type RenderBlockProps = {
|
|
3
|
+
block: BuilderBlock;
|
|
4
|
+
context: BuilderContextInterface;
|
|
5
|
+
}; // eslint-disable-next-line @builder.io/mitosis/only-default-function-and-imports
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
3
9
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
4
10
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
5
11
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
@@ -12,23 +18,22 @@
|
|
|
12
18
|
import RenderComponent from "./render-component.svelte";
|
|
13
19
|
import RenderRepeatedBlock from "./render-repeated-block.svelte";
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export let block;
|
|
21
|
+
export let block: RenderBlockProps["block"];
|
|
22
|
+
export let context: RenderBlockProps["context"];
|
|
18
23
|
|
|
19
24
|
$: component = () => {
|
|
20
25
|
const componentName = getProcessedBlock({
|
|
21
26
|
block: block,
|
|
22
|
-
state:
|
|
23
|
-
context:
|
|
24
|
-
|
|
27
|
+
state: context.state,
|
|
28
|
+
context: context.context,
|
|
29
|
+
shouldEvaluateBindings: false,
|
|
25
30
|
}).component?.name;
|
|
26
31
|
|
|
27
32
|
if (!componentName) {
|
|
28
33
|
return null;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
const ref =
|
|
36
|
+
const ref = context.registeredComponents[componentName];
|
|
32
37
|
|
|
33
38
|
if (!ref) {
|
|
34
39
|
// TODO: Public doc page with more info about this message
|
|
@@ -63,9 +68,9 @@
|
|
|
63
68
|
? block
|
|
64
69
|
: getProcessedBlock({
|
|
65
70
|
block: block,
|
|
66
|
-
state:
|
|
67
|
-
context:
|
|
68
|
-
|
|
71
|
+
state: context.state,
|
|
72
|
+
context: context.context,
|
|
73
|
+
shouldEvaluateBindings: true,
|
|
69
74
|
});
|
|
70
75
|
};
|
|
71
76
|
|
|
@@ -74,8 +79,8 @@
|
|
|
74
79
|
...getBlockProperties(useBlock()),
|
|
75
80
|
...getBlockActions({
|
|
76
81
|
block: useBlock(),
|
|
77
|
-
state:
|
|
78
|
-
context:
|
|
82
|
+
state: context.state,
|
|
83
|
+
context: context.context,
|
|
79
84
|
}),
|
|
80
85
|
style: getBlockStyles(useBlock()),
|
|
81
86
|
};
|
|
@@ -106,6 +111,7 @@
|
|
|
106
111
|
blockChildren: children(),
|
|
107
112
|
componentRef: componentRef(),
|
|
108
113
|
componentOptions: componentOptions(),
|
|
114
|
+
context: context,
|
|
109
115
|
};
|
|
110
116
|
};
|
|
111
117
|
|
|
@@ -141,8 +147,8 @@
|
|
|
141
147
|
|
|
142
148
|
const itemsArray = evaluate({
|
|
143
149
|
code: repeat.collection,
|
|
144
|
-
state:
|
|
145
|
-
context:
|
|
150
|
+
state: context.state,
|
|
151
|
+
context: context.context,
|
|
146
152
|
});
|
|
147
153
|
|
|
148
154
|
if (!Array.isArray(itemsArray)) {
|
|
@@ -154,9 +160,9 @@
|
|
|
154
160
|
repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
155
161
|
const repeatArray = itemsArray.map((item, index) => ({
|
|
156
162
|
context: {
|
|
157
|
-
...
|
|
163
|
+
...context,
|
|
158
164
|
state: {
|
|
159
|
-
...
|
|
165
|
+
...context.state,
|
|
160
166
|
$index: index,
|
|
161
167
|
$item: item,
|
|
162
168
|
[itemNameToUse]: item,
|
|
@@ -167,8 +173,6 @@
|
|
|
167
173
|
}));
|
|
168
174
|
return repeatArray;
|
|
169
175
|
};
|
|
170
|
-
|
|
171
|
-
let builderContext = getContext(BuilderContext.key);
|
|
172
176
|
</script>
|
|
173
177
|
|
|
174
178
|
{#if shouldWrap()}
|
|
@@ -187,17 +191,17 @@
|
|
|
187
191
|
<RenderComponent {...renderComponentProps()} />
|
|
188
192
|
{/if}
|
|
189
193
|
|
|
190
|
-
{#each childrenWithoutParentComponent() as child
|
|
191
|
-
<svelte:self block={child} />
|
|
194
|
+
{#each childrenWithoutParentComponent() as child ("render-block-" + child.id)}
|
|
195
|
+
<svelte:self block={child} {context} />
|
|
192
196
|
{/each}
|
|
193
197
|
|
|
194
|
-
{#each childrenWithoutParentComponent() as child
|
|
195
|
-
<BlockStyles block={child} />
|
|
198
|
+
{#each childrenWithoutParentComponent() as child ("block-style-" + child.id)}
|
|
199
|
+
<BlockStyles block={child} {context} />
|
|
196
200
|
{/each}
|
|
197
201
|
</svelte:element>
|
|
198
202
|
{:else}
|
|
199
203
|
<svelte:element this={tagName()} {...attributes()} />
|
|
200
204
|
{/if}
|
|
201
205
|
{:else}
|
|
202
|
-
<RenderComponent {...renderComponentProps()} />
|
|
206
|
+
<RenderComponent {...renderComponentProps()} {context} />
|
|
203
207
|
{/if}
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export interface RenderComponentProps {
|
|
3
|
+
componentRef: any;
|
|
4
|
+
componentOptions: any;
|
|
5
|
+
blockChildren: BuilderBlock[];
|
|
6
|
+
context: BuilderContextInterface;
|
|
7
|
+
} // eslint-disable-next-line @builder.io/mitosis/only-default-function-and-imports
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
2
11
|
import BlockStyles from "./block-styles.svelte";
|
|
3
12
|
import RenderBlock from "./render-block.svelte";
|
|
4
13
|
|
|
5
|
-
export let componentRef;
|
|
6
|
-
export let componentOptions;
|
|
7
|
-
export let blockChildren;
|
|
14
|
+
export let componentRef: RenderComponentProps["componentRef"];
|
|
15
|
+
export let componentOptions: RenderComponentProps["componentOptions"];
|
|
16
|
+
export let blockChildren: RenderComponentProps["blockChildren"];
|
|
17
|
+
export let context: RenderComponentProps["context"];
|
|
8
18
|
</script>
|
|
9
19
|
|
|
10
20
|
{#if componentRef}
|
|
11
21
|
<svelte:component this={componentRef} {...componentOptions}>
|
|
12
|
-
{#each blockChildren as child
|
|
13
|
-
<RenderBlock block={child} />
|
|
22
|
+
{#each blockChildren as child ("render-block-" + child.id)}
|
|
23
|
+
<RenderBlock block={child} {context} />
|
|
14
24
|
{/each}
|
|
15
25
|
|
|
16
|
-
{#each blockChildren as child
|
|
17
|
-
<BlockStyles block={child} />
|
|
26
|
+
{#each blockChildren as child ("block-style-" + child.id)}
|
|
27
|
+
<BlockStyles block={child} {context} />
|
|
18
28
|
{/each}
|
|
19
29
|
</svelte:component>
|
|
20
30
|
{/if}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
import type { BuilderBlock } from "../../types/builder-block";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
block: BuilderBlock;
|
|
6
|
+
repeatContext: BuilderContextInterface;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* We can't make this a generic `ProvideContext` function because Vue 2 won't support root slots, e.g.
|
|
10
|
+
*
|
|
11
|
+
* ```vue
|
|
12
|
+
* <template>
|
|
13
|
+
* <slot></slot>
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
3
21
|
import RenderBlock from "./render-block.svelte";
|
|
4
22
|
|
|
5
23
|
import { getContext, setContext } from "svelte";
|
|
6
24
|
|
|
7
|
-
export let block;
|
|
8
|
-
export let repeatContext;
|
|
25
|
+
export let block: Props["block"];
|
|
26
|
+
export let repeatContext: Props["repeatContext"];
|
|
9
27
|
|
|
10
28
|
setContext(BuilderContext.key, {
|
|
11
29
|
get content() {
|
|
@@ -26,4 +44,4 @@
|
|
|
26
44
|
});
|
|
27
45
|
</script>
|
|
28
46
|
|
|
29
|
-
<RenderBlock {block} />
|
|
47
|
+
<RenderBlock {block} context={repeatContext} />
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type RenderBlockProps = {
|
|
3
|
+
blocks?: BuilderBlock[];
|
|
4
|
+
parent?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
};
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import BuilderContext from "../context/builder.context.js";
|
|
2
11
|
import { isEditing } from "../functions/is-editing.js";
|
|
3
12
|
import BlockStyles from "./render-block/block-styles.svelte";
|
|
4
13
|
import RenderBlock from "./render-block/render-block.svelte";
|
|
5
14
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let
|
|
15
|
+
import { getContext, setContext } from "svelte";
|
|
16
|
+
|
|
17
|
+
export let blocks: RenderBlockProps["blocks"];
|
|
18
|
+
export let parent: RenderBlockProps["parent"];
|
|
19
|
+
export let path: RenderBlockProps["path"];
|
|
20
|
+
|
|
21
|
+
let builderContext = getContext(BuilderContext.key);
|
|
9
22
|
|
|
10
23
|
const onClick = function onClick() {
|
|
11
24
|
if (isEditing() && !blocks?.length) {
|
|
@@ -56,14 +69,14 @@
|
|
|
56
69
|
}}
|
|
57
70
|
>
|
|
58
71
|
{#if blocks}
|
|
59
|
-
{#each blocks as block
|
|
60
|
-
<RenderBlock {block} />
|
|
72
|
+
{#each blocks as block ("render-block-" + block.id)}
|
|
73
|
+
<RenderBlock {block} context={builderContext} />
|
|
61
74
|
{/each}
|
|
62
75
|
{/if}
|
|
63
76
|
|
|
64
77
|
{#if blocks}
|
|
65
|
-
{#each blocks as block
|
|
66
|
-
<BlockStyles {block} />
|
|
78
|
+
{#each blocks as block ("block-style-" + block.id)}
|
|
79
|
+
<BlockStyles {block} context={builderContext} />
|
|
67
80
|
{/each}
|
|
68
81
|
{/if}
|
|
69
82
|
</div>
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
interface CustomFont {
|
|
3
|
+
family?: string;
|
|
4
|
+
kind?: string;
|
|
5
|
+
fileUrl?: string;
|
|
6
|
+
files?: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
cssCode?: string;
|
|
13
|
+
customFonts?: CustomFont[];
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
2
18
|
import RenderInlinedStyles from "../../render-inlined-styles.svelte";
|
|
3
19
|
|
|
4
|
-
export let cssCode;
|
|
5
|
-
export let customFonts;
|
|
20
|
+
export let cssCode: Props["cssCode"];
|
|
21
|
+
export let customFonts: Props["customFonts"];
|
|
6
22
|
|
|
7
23
|
const getCssFromFont = function getCssFromFont(font) {
|
|
8
24
|
// TODO: compute what font sizes are used and only load those.......
|
|
@@ -1,11 +1,37 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type RenderContentProps = {
|
|
3
|
+
content?: Nullable<BuilderContent>;
|
|
4
|
+
model?: string;
|
|
5
|
+
data?: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
context?: BuilderRenderContext;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
customComponents?: RegisteredComponent[];
|
|
11
|
+
canTrack?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface BuilderComponentStateChange {
|
|
15
|
+
state: BuilderRenderState;
|
|
16
|
+
ref: {
|
|
17
|
+
name?: string;
|
|
18
|
+
props?: {
|
|
19
|
+
builderBlock?: {
|
|
20
|
+
id?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
2
28
|
import { onMount } from "svelte";
|
|
3
29
|
import { afterUpdate } from "svelte";
|
|
4
30
|
import { onDestroy } from "svelte";
|
|
5
31
|
|
|
6
32
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
7
33
|
import { TARGET } from "../../constants/target.js";
|
|
8
|
-
import BuilderContext from "../../context/builder.context";
|
|
34
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
9
35
|
import { evaluate } from "../../functions/evaluate.js";
|
|
10
36
|
import { getContent } from "../../functions/get-content/index.js";
|
|
11
37
|
import { getFetch } from "../../functions/get-fetch.js";
|
|
@@ -19,16 +45,39 @@
|
|
|
19
45
|
import { track } from "../../functions/track.js";
|
|
20
46
|
import RenderBlocks from "../render-blocks.svelte";
|
|
21
47
|
import RenderContentStyles from "./components/render-styles.svelte";
|
|
48
|
+
import {
|
|
49
|
+
registerInsertMenu,
|
|
50
|
+
setupBrowserForEditing,
|
|
51
|
+
} from "../../scripts/init-editing.js";
|
|
22
52
|
|
|
23
53
|
import { getContext, setContext } from "svelte";
|
|
24
54
|
|
|
25
|
-
export let
|
|
26
|
-
export let
|
|
27
|
-
export let
|
|
28
|
-
export let
|
|
29
|
-
export let
|
|
30
|
-
export let
|
|
31
|
-
export let
|
|
55
|
+
export let elementRef: RenderContentProps["elementRef"];
|
|
56
|
+
export let content: RenderContentProps["content"];
|
|
57
|
+
export let data: RenderContentProps["data"];
|
|
58
|
+
export let canTrack: RenderContentProps["canTrack"];
|
|
59
|
+
export let context: RenderContentProps["context"];
|
|
60
|
+
export let customComponents: RenderContentProps["customComponents"];
|
|
61
|
+
export let model: RenderContentProps["model"];
|
|
62
|
+
export let apiKey: RenderContentProps["apiKey"];
|
|
63
|
+
|
|
64
|
+
setContext(BuilderContext.key, {
|
|
65
|
+
get content() {
|
|
66
|
+
return useContent();
|
|
67
|
+
},
|
|
68
|
+
get state() {
|
|
69
|
+
return contentState();
|
|
70
|
+
},
|
|
71
|
+
get context() {
|
|
72
|
+
return contextContext();
|
|
73
|
+
},
|
|
74
|
+
get apiKey() {
|
|
75
|
+
return apiKey;
|
|
76
|
+
},
|
|
77
|
+
get registeredComponents() {
|
|
78
|
+
return allRegisteredComponents();
|
|
79
|
+
},
|
|
80
|
+
});
|
|
32
81
|
|
|
33
82
|
const processMessage = function processMessage(event) {
|
|
34
83
|
const { data } = event;
|
|
@@ -73,9 +122,12 @@
|
|
|
73
122
|
};
|
|
74
123
|
|
|
75
124
|
const onClick = function onClick(_event) {
|
|
76
|
-
if (useContent()
|
|
77
|
-
track(
|
|
125
|
+
if (useContent()) {
|
|
126
|
+
track({
|
|
127
|
+
type: "click",
|
|
128
|
+
canTrack: canTrackToUse(),
|
|
78
129
|
contentId: useContent().id,
|
|
130
|
+
orgId: apiKey,
|
|
79
131
|
});
|
|
80
132
|
}
|
|
81
133
|
};
|
|
@@ -138,6 +190,10 @@
|
|
|
138
190
|
return mergedContent;
|
|
139
191
|
};
|
|
140
192
|
|
|
193
|
+
$: canTrackToUse = () => {
|
|
194
|
+
return canTrack || true;
|
|
195
|
+
};
|
|
196
|
+
|
|
141
197
|
$: contentState = () => {
|
|
142
198
|
return { ...content?.data?.state, ...data, ...overrideState };
|
|
143
199
|
};
|
|
@@ -175,23 +231,7 @@
|
|
|
175
231
|
);
|
|
176
232
|
};
|
|
177
233
|
|
|
178
|
-
|
|
179
|
-
get content() {
|
|
180
|
-
return useContent();
|
|
181
|
-
},
|
|
182
|
-
get state() {
|
|
183
|
-
return contentState();
|
|
184
|
-
},
|
|
185
|
-
get context() {
|
|
186
|
-
return contextContext();
|
|
187
|
-
},
|
|
188
|
-
get apiKey() {
|
|
189
|
-
return apiKey;
|
|
190
|
-
},
|
|
191
|
-
get registeredComponents() {
|
|
192
|
-
return allRegisteredComponents();
|
|
193
|
-
},
|
|
194
|
-
});
|
|
234
|
+
let forceReRenderCount = 0;
|
|
195
235
|
let overrideContent = null;
|
|
196
236
|
let update = 0;
|
|
197
237
|
let overrideState = {};
|
|
@@ -199,6 +239,10 @@
|
|
|
199
239
|
onMount(() => {
|
|
200
240
|
if (isBrowser()) {
|
|
201
241
|
if (isEditing()) {
|
|
242
|
+
forceReRenderCount = forceReRenderCount + 1; // QWIK-REPLACE: _useMutableProps
|
|
243
|
+
|
|
244
|
+
registerInsertMenu();
|
|
245
|
+
setupBrowserForEditing();
|
|
202
246
|
Object.values(allRegisteredComponents()).forEach(
|
|
203
247
|
(registeredComponent) => {
|
|
204
248
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
@@ -212,9 +256,12 @@
|
|
|
212
256
|
);
|
|
213
257
|
}
|
|
214
258
|
|
|
215
|
-
if (useContent()
|
|
216
|
-
track(
|
|
259
|
+
if (useContent()) {
|
|
260
|
+
track({
|
|
261
|
+
type: "impression",
|
|
262
|
+
canTrack: canTrackToUse(),
|
|
217
263
|
contentId: useContent().id,
|
|
264
|
+
orgId: apiKey,
|
|
218
265
|
});
|
|
219
266
|
} // override normal content in preview mode
|
|
220
267
|
|
|
@@ -270,6 +317,7 @@
|
|
|
270
317
|
|
|
271
318
|
{#if useContent()}
|
|
272
319
|
<div
|
|
320
|
+
bind:this={elementRef}
|
|
273
321
|
on:click={(event) => {
|
|
274
322
|
onClick(event);
|
|
275
323
|
}}
|
|
@@ -281,7 +329,9 @@
|
|
|
281
329
|
customFonts={useContent?.()?.data?.customFonts}
|
|
282
330
|
/>
|
|
283
331
|
{/if}
|
|
284
|
-
|
|
285
|
-
|
|
332
|
+
<RenderBlocks
|
|
333
|
+
blocks={useContent?.()?.data?.blocks}
|
|
334
|
+
key={forceReRenderCount}
|
|
335
|
+
/>
|
|
286
336
|
</div>
|
|
287
337
|
{/if}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
styles: string;
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
2
8
|
import { TARGET } from "../constants/target.js";
|
|
3
9
|
|
|
4
|
-
export let styles;
|
|
10
|
+
export let styles: Props["styles"];
|
|
5
11
|
|
|
6
12
|
$: injectedStyleScript = () => {
|
|
7
13
|
return `<${tagName()}>${styles}</${tagName()}>`;
|
|
@@ -15,26 +15,29 @@ var __spreadValues = (a, b) => {
|
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
17
|
import { default as Button } from "../blocks/button/button.svelte";
|
|
18
|
-
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info.js";
|
|
19
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";
|
|
20
|
+
import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info.js";
|
|
21
|
+
import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info.js";
|
|
22
22
|
import { default as Fragment } from "../blocks/fragment/fragment.svelte";
|
|
23
|
-
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info.js";
|
|
24
24
|
import { default as Image } from "../blocks/image/image.svelte";
|
|
25
|
-
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info.js";
|
|
26
26
|
import { default as Section } from "../blocks/section/section.svelte";
|
|
27
|
-
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info.js";
|
|
28
28
|
import { default as Symbol } from "../blocks/symbol/symbol.svelte";
|
|
29
|
-
import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info.js";
|
|
30
30
|
import { default as Text } from "../blocks/text/text.svelte";
|
|
31
|
-
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info.js";
|
|
32
32
|
import { default as Video } from "../blocks/video/video.svelte";
|
|
33
|
-
import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info";
|
|
33
|
+
import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info.js";
|
|
34
34
|
import { default as embed } from "../blocks/embed/embed.svelte";
|
|
35
|
+
import { default as Img } from "../blocks/img/img.svelte";
|
|
36
|
+
import { componentInfo as imgComponentInfo } from "../blocks/img/component-info.js";
|
|
35
37
|
const getDefaultRegisteredComponents = () => [
|
|
36
38
|
__spreadValues({ component: Columns }, columnsComponentInfo),
|
|
37
39
|
__spreadValues({ component: Image }, imageComponentInfo),
|
|
40
|
+
__spreadValues({ component: Img }, imgComponentInfo),
|
|
38
41
|
__spreadValues({ component: Text }, textComponentInfo),
|
|
39
42
|
__spreadValues({ component: Video }, videoComponentInfo),
|
|
40
43
|
__spreadValues({ component: Symbol }, symbolComponentInfo),
|