@builder.io/sdk-svelte 0.0.1-31 → 0.0.1-32
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 +27 -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 +9 -3
- 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 +33 -14
- 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 +23 -3
- 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 +20 -4
- 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 +67 -27
- package/src/components/render-inlined-styles.svelte +8 -2
- package/src/constants/builder-registered-components.js +3 -0
- 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/scripts/init-editing.js +4 -5
|
@@ -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,27 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
type Props = {
|
|
3
|
+
block: BuilderBlock;
|
|
4
|
+
repeatContext: BuilderContextInterface;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* We can't make this a generic `ProvideContext` function because Vue 2 won't support root slots, e.g.
|
|
8
|
+
*
|
|
9
|
+
* ```vue
|
|
10
|
+
* <template>
|
|
11
|
+
* <slot></slot>
|
|
12
|
+
* </template>
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
2
18
|
import BuilderContext from "../../context/builder.context";
|
|
3
19
|
import RenderBlock from "./render-block.svelte";
|
|
4
20
|
|
|
5
21
|
import { getContext, setContext } from "svelte";
|
|
6
22
|
|
|
7
|
-
export let block;
|
|
8
|
-
export let repeatContext;
|
|
23
|
+
export let block: Props["block"];
|
|
24
|
+
export let repeatContext: Props["repeatContext"];
|
|
9
25
|
|
|
10
26
|
setContext(BuilderContext.key, {
|
|
11
27
|
get content() {
|
|
@@ -26,4 +42,4 @@
|
|
|
26
42
|
});
|
|
27
43
|
</script>
|
|
28
44
|
|
|
29
|
-
<RenderBlock {block} />
|
|
45
|
+
<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";
|
|
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,4 +1,30 @@
|
|
|
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";
|
|
@@ -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;
|
|
@@ -182,23 +231,7 @@
|
|
|
182
231
|
);
|
|
183
232
|
};
|
|
184
233
|
|
|
185
|
-
|
|
186
|
-
get content() {
|
|
187
|
-
return useContent();
|
|
188
|
-
},
|
|
189
|
-
get state() {
|
|
190
|
-
return contentState();
|
|
191
|
-
},
|
|
192
|
-
get context() {
|
|
193
|
-
return contextContext();
|
|
194
|
-
},
|
|
195
|
-
get apiKey() {
|
|
196
|
-
return apiKey;
|
|
197
|
-
},
|
|
198
|
-
get registeredComponents() {
|
|
199
|
-
return allRegisteredComponents();
|
|
200
|
-
},
|
|
201
|
-
});
|
|
234
|
+
let forceReRenderCount = 0;
|
|
202
235
|
let overrideContent = null;
|
|
203
236
|
let update = 0;
|
|
204
237
|
let overrideState = {};
|
|
@@ -206,6 +239,10 @@
|
|
|
206
239
|
onMount(() => {
|
|
207
240
|
if (isBrowser()) {
|
|
208
241
|
if (isEditing()) {
|
|
242
|
+
forceReRenderCount = forceReRenderCount + 1; // QWIK-REPLACE: _useMutableProps
|
|
243
|
+
|
|
244
|
+
registerInsertMenu();
|
|
245
|
+
setupBrowserForEditing();
|
|
209
246
|
Object.values(allRegisteredComponents()).forEach(
|
|
210
247
|
(registeredComponent) => {
|
|
211
248
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
@@ -280,6 +317,7 @@
|
|
|
280
317
|
|
|
281
318
|
{#if useContent()}
|
|
282
319
|
<div
|
|
320
|
+
bind:this={elementRef}
|
|
283
321
|
on:click={(event) => {
|
|
284
322
|
onClick(event);
|
|
285
323
|
}}
|
|
@@ -291,7 +329,9 @@
|
|
|
291
329
|
customFonts={useContent?.()?.data?.customFonts}
|
|
292
330
|
/>
|
|
293
331
|
{/if}
|
|
294
|
-
|
|
295
|
-
|
|
332
|
+
<RenderBlocks
|
|
333
|
+
blocks={useContent?.()?.data?.blocks}
|
|
334
|
+
key={forceReRenderCount}
|
|
335
|
+
/>
|
|
296
336
|
</div>
|
|
297
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()}>`;
|
|
@@ -32,9 +32,12 @@ import { componentInfo as videoComponentInfo } from "../blocks/video/component-i
|
|
|
32
32
|
import { default as Video } from "../blocks/video/video.svelte";
|
|
33
33
|
import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info";
|
|
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";
|
|
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),
|
|
@@ -24,9 +24,9 @@ function getFetch() {
|
|
|
24
24
|
const globalFetch = getGlobalThis().fetch;
|
|
25
25
|
if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
|
|
26
26
|
const nodeFetch = import("node-fetch").then((d) => d.default);
|
|
27
|
-
return nodeFetch;
|
|
27
|
+
return nodeFetch.default || nodeFetch;
|
|
28
28
|
}
|
|
29
|
-
return globalFetch;
|
|
29
|
+
return globalFetch.default || globalFetch;
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
export {
|
|
@@ -39,13 +39,17 @@ const evaluateBindings = ({
|
|
|
39
39
|
}
|
|
40
40
|
return copied;
|
|
41
41
|
};
|
|
42
|
-
function getProcessedBlock(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
function getProcessedBlock({
|
|
43
|
+
block,
|
|
44
|
+
context,
|
|
45
|
+
shouldEvaluateBindings,
|
|
46
|
+
state
|
|
47
|
+
}) {
|
|
48
|
+
const transformedBlock = transformBlock(block);
|
|
49
|
+
if (shouldEvaluateBindings) {
|
|
50
|
+
return evaluateBindings({ block: transformedBlock, state, context });
|
|
47
51
|
} else {
|
|
48
|
-
return
|
|
52
|
+
return transformedBlock;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
export {
|
|
@@ -21,7 +21,7 @@ test("Can process bindings", () => {
|
|
|
21
21
|
block,
|
|
22
22
|
context: {},
|
|
23
23
|
state: { test: "hello" },
|
|
24
|
-
|
|
24
|
+
shouldEvaluateBindings: true
|
|
25
25
|
});
|
|
26
26
|
expect(processed).not.toEqual(block);
|
|
27
27
|
expect((_a = processed.properties) == null ? void 0 : _a.foo).toEqual("baz");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TARGET } from "../constants/target.js";
|
|
2
2
|
import { isBrowser } from "../functions/is-browser.js";
|
|
3
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
4
3
|
import { register } from "../functions/register.js";
|
|
5
4
|
const registerInsertMenu = () => {
|
|
6
5
|
register("insertMenu", {
|
|
@@ -74,7 +73,7 @@ const setupBrowserForEditing = () => {
|
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
};
|
|
77
|
-
|
|
78
|
-
registerInsertMenu
|
|
79
|
-
setupBrowserForEditing
|
|
80
|
-
}
|
|
76
|
+
export {
|
|
77
|
+
registerInsertMenu,
|
|
78
|
+
setupBrowserForEditing
|
|
79
|
+
};
|