@builder.io/sdk-svelte 0.12.0 → 0.12.2
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/lib/browser/blocks/slot/component-info.d.ts +2 -0
- package/lib/browser/blocks/slot/component-info.js +14 -0
- package/lib/browser/blocks/slot/slot.svelte +33 -0
- package/lib/browser/blocks/slot/slot.svelte.d.ts +26 -0
- package/lib/browser/blocks/symbol/symbol.svelte +5 -1
- package/lib/browser/blocks/symbol/symbol.svelte.d.ts +1 -0
- package/lib/browser/components/block/block.helpers.d.ts +0 -1
- package/lib/browser/components/block/block.helpers.js +0 -7
- package/lib/browser/components/block/block.svelte +11 -27
- package/lib/browser/components/block/components/block-wrapper.svelte +18 -44
- package/lib/browser/components/block/components/block-wrapper.svelte.d.ts +0 -5
- package/lib/browser/components/content/components/enable-editor.svelte +10 -0
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +1 -0
- package/lib/browser/components/content/content.svelte +2 -0
- package/lib/browser/components/content/content.svelte.d.ts +1 -0
- package/lib/browser/components/content-variants/content-variants.svelte +3 -0
- package/lib/browser/components/content-variants/content-variants.svelte.d.ts +1 -0
- package/lib/browser/components/content-variants/content-variants.types.d.ts +4 -0
- package/lib/browser/components/dynamic-renderer/dynamic-renderer.helpers.d.ts +1 -0
- package/lib/browser/components/dynamic-renderer/dynamic-renderer.helpers.js +7 -0
- package/lib/browser/components/dynamic-renderer/dynamic-renderer.svelte +28 -0
- package/lib/browser/components/dynamic-renderer/dynamic-renderer.svelte.d.ts +21 -0
- package/lib/browser/constants/builder-registered-components.js +5 -0
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/is-from-trusted-host.d.ts +3 -0
- package/lib/browser/functions/is-from-trusted-host.js +5 -0
- package/lib/browser/scripts/init-editing.d.ts +1 -0
- package/lib/browser/scripts/init-editing.js +6 -1
- package/lib/edge/blocks/slot/component-info.d.ts +2 -0
- package/lib/edge/blocks/slot/component-info.js +14 -0
- package/lib/edge/blocks/slot/slot.svelte +33 -0
- package/lib/edge/blocks/slot/slot.svelte.d.ts +26 -0
- package/lib/edge/blocks/symbol/symbol.svelte +5 -1
- package/lib/edge/blocks/symbol/symbol.svelte.d.ts +1 -0
- package/lib/edge/components/block/block.helpers.d.ts +0 -1
- package/lib/edge/components/block/block.helpers.js +0 -7
- package/lib/edge/components/block/block.svelte +11 -27
- package/lib/edge/components/block/components/block-wrapper.svelte +18 -44
- package/lib/edge/components/block/components/block-wrapper.svelte.d.ts +0 -5
- package/lib/edge/components/content/components/enable-editor.svelte +10 -0
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +1 -0
- package/lib/edge/components/content/content.svelte +2 -0
- package/lib/edge/components/content/content.svelte.d.ts +1 -0
- package/lib/edge/components/content-variants/content-variants.svelte +3 -0
- package/lib/edge/components/content-variants/content-variants.svelte.d.ts +1 -0
- package/lib/edge/components/content-variants/content-variants.types.d.ts +4 -0
- package/lib/edge/components/dynamic-renderer/dynamic-renderer.helpers.d.ts +1 -0
- package/lib/edge/components/dynamic-renderer/dynamic-renderer.helpers.js +7 -0
- package/lib/edge/components/dynamic-renderer/dynamic-renderer.svelte +28 -0
- package/lib/edge/components/dynamic-renderer/dynamic-renderer.svelte.d.ts +21 -0
- package/lib/edge/constants/builder-registered-components.js +5 -0
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/is-from-trusted-host.d.ts +3 -0
- package/lib/edge/functions/is-from-trusted-host.js +5 -0
- package/lib/edge/scripts/init-editing.d.ts +1 -0
- package/lib/edge/scripts/init-editing.js +6 -1
- package/lib/node/blocks/slot/component-info.d.ts +2 -0
- package/lib/node/blocks/slot/component-info.js +14 -0
- package/lib/node/blocks/slot/slot.svelte +33 -0
- package/lib/node/blocks/slot/slot.svelte.d.ts +26 -0
- package/lib/node/blocks/symbol/symbol.svelte +5 -1
- package/lib/node/blocks/symbol/symbol.svelte.d.ts +1 -0
- package/lib/node/components/block/block.helpers.d.ts +0 -1
- package/lib/node/components/block/block.helpers.js +0 -7
- package/lib/node/components/block/block.svelte +11 -27
- package/lib/node/components/block/components/block-wrapper.svelte +18 -44
- package/lib/node/components/block/components/block-wrapper.svelte.d.ts +0 -5
- package/lib/node/components/content/components/enable-editor.svelte +10 -0
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +1 -0
- package/lib/node/components/content/content.svelte +2 -0
- package/lib/node/components/content/content.svelte.d.ts +1 -0
- package/lib/node/components/content-variants/content-variants.svelte +3 -0
- package/lib/node/components/content-variants/content-variants.svelte.d.ts +1 -0
- package/lib/node/components/content-variants/content-variants.types.d.ts +4 -0
- package/lib/node/components/dynamic-renderer/dynamic-renderer.helpers.d.ts +1 -0
- package/lib/node/components/dynamic-renderer/dynamic-renderer.helpers.js +7 -0
- package/lib/node/components/dynamic-renderer/dynamic-renderer.svelte +28 -0
- package/lib/node/components/dynamic-renderer/dynamic-renderer.svelte.d.ts +21 -0
- package/lib/node/constants/builder-registered-components.js +5 -0
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/is-from-trusted-host.d.ts +3 -0
- package/lib/node/functions/is-from-trusted-host.js +5 -0
- package/lib/node/scripts/init-editing.d.ts +1 -0
- package/lib/node/scripts/init-editing.js +6 -1
- package/package.json +1 -1
- package/src/blocks/slot/component-info.ts +15 -0
- package/src/blocks/slot/slot.svelte +45 -0
- package/src/blocks/symbol/symbol.svelte +5 -1
- package/src/components/block/block.helpers.ts +0 -8
- package/src/components/block/block.svelte +11 -31
- package/src/components/block/components/block-wrapper.svelte +18 -46
- package/src/components/content/components/enable-editor.svelte +10 -0
- package/src/components/content/content.svelte +2 -0
- package/src/components/content-variants/content-variants.svelte +3 -0
- package/src/components/content-variants/content-variants.types.ts +5 -0
- package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
- package/src/components/dynamic-renderer/dynamic-renderer.svelte +43 -0
- package/src/constants/builder-registered-components.ts +5 -0
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/is-from-trusted-host.ts +8 -0
- package/src/scripts/init-editing.ts +9 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const componentInfo = {
|
|
2
|
+
name: 'Slot',
|
|
3
|
+
isRSC: true,
|
|
4
|
+
description: 'Allow child blocks to be inserted into this content when used as a Symbol',
|
|
5
|
+
docsLink: 'https://www.builder.io/c/docs/symbols-with-blocks',
|
|
6
|
+
image: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56',
|
|
7
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
8
|
+
inputs: [{
|
|
9
|
+
name: 'name',
|
|
10
|
+
type: 'string',
|
|
11
|
+
required: true,
|
|
12
|
+
defaultValue: 'children'
|
|
13
|
+
}]
|
|
14
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import Blocks from "../../components/blocks/blocks.svelte";
|
|
4
|
+
import "../../functions/deopt.js";
|
|
5
|
+
export let builderContext;
|
|
6
|
+
export let name;
|
|
7
|
+
function mitosis_styling(node, vars) {
|
|
8
|
+
Object.entries(vars || {}).forEach(([p, v]) => {
|
|
9
|
+
if (p.startsWith("--")) {
|
|
10
|
+
node.style.setProperty(p, v);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
node.style[p] = v;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
use:mitosis_styling={{
|
|
21
|
+
pointerEvents: "auto",
|
|
22
|
+
}}
|
|
23
|
+
{...!$builderContext.context?.symbolId && {
|
|
24
|
+
"builder-slot": name,
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<Blocks
|
|
28
|
+
parent={$builderContext.context?.symbolId}
|
|
29
|
+
path={`symbol.data.${name}`}
|
|
30
|
+
context={builderContext}
|
|
31
|
+
blocks={$builderContext.rootState?.[name]}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
export interface DropzoneProps {
|
|
3
|
+
name: string;
|
|
4
|
+
builderBlock: BuilderBlock;
|
|
5
|
+
builderContext: Writable<BuilderContextInterface>;
|
|
6
|
+
attributes: any;
|
|
7
|
+
}
|
|
8
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
9
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
10
|
+
import type { Writable } from "svelte/store";
|
|
11
|
+
declare const __propDef: {
|
|
12
|
+
props: {
|
|
13
|
+
builderContext: DropzoneProps["builderContext"];
|
|
14
|
+
name: DropzoneProps["name"];
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
};
|
|
21
|
+
export type SlotProps = typeof __propDef.props;
|
|
22
|
+
export type SlotEvents = typeof __propDef.events;
|
|
23
|
+
export type SlotSlots = typeof __propDef.slots;
|
|
24
|
+
export default class Slot extends SvelteComponent<SlotProps, SlotEvents, SlotSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -8,6 +8,7 @@ export let attributes = undefined;
|
|
|
8
8
|
export let symbol = undefined;
|
|
9
9
|
export let dynamic = undefined;
|
|
10
10
|
export let builderContext;
|
|
11
|
+
export let builderBlock;
|
|
11
12
|
export let builderComponents;
|
|
12
13
|
function setContent() {
|
|
13
14
|
if (contentToUse)
|
|
@@ -51,7 +52,10 @@ $: onUpdateFn_0(...[symbol]);
|
|
|
51
52
|
__isNestedRender={true}
|
|
52
53
|
apiVersion={$builderContext.apiVersion}
|
|
53
54
|
apiKey={$builderContext.apiKey}
|
|
54
|
-
context={
|
|
55
|
+
context={{
|
|
56
|
+
...$builderContext.context,
|
|
57
|
+
symbolId: builderBlock?.id,
|
|
58
|
+
}}
|
|
55
59
|
customComponents={Object.values(builderComponents)}
|
|
56
60
|
data={{
|
|
57
61
|
...symbol?.data,
|
|
@@ -8,6 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
symbol?: PropsWithBuilderData<SymbolProps>["symbol"];
|
|
9
9
|
dynamic?: PropsWithBuilderData<SymbolProps>["dynamic"];
|
|
10
10
|
builderContext: PropsWithBuilderData<SymbolProps>["builderContext"];
|
|
11
|
+
builderBlock: PropsWithBuilderData<SymbolProps>["builderBlock"];
|
|
11
12
|
builderComponents: PropsWithBuilderData<SymbolProps>["builderComponents"];
|
|
12
13
|
};
|
|
13
14
|
events: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BuilderContextInterface, RegisteredComponents } from '../../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../../types/builder-block.js';
|
|
3
3
|
import type { RepeatData } from './types.js';
|
|
4
|
-
export declare const isEmptyHtmlElement: (tagName: unknown) => boolean;
|
|
5
4
|
export declare const getComponent: ({ block, context, registeredComponents }: {
|
|
6
5
|
block: BuilderBlock;
|
|
7
6
|
context: BuilderContextInterface;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { evaluate } from '../../functions/evaluate/index.js';
|
|
2
2
|
import { getProcessedBlock } from '../../functions/get-processed-block.js';
|
|
3
|
-
/**
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
|
5
|
-
*/
|
|
6
|
-
const EMPTY_HTML_ELEMENTS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
7
|
-
export const isEmptyHtmlElement = (tagName) => {
|
|
8
|
-
return typeof tagName === 'string' && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
9
|
-
};
|
|
10
3
|
export const getComponent = ({ block, context, registeredComponents }) => {
|
|
11
4
|
const componentName = getProcessedBlock({
|
|
12
5
|
block,
|
|
@@ -5,7 +5,7 @@ import "../../functions/extract-text-styles.js";
|
|
|
5
5
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
6
6
|
import "../../functions/get-block-properties.js";
|
|
7
7
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import { getComponent, getRepeatItemData
|
|
8
|
+
import { getComponent, getRepeatItemData } from "./block.helpers.js";
|
|
9
9
|
import BlockStyles from "./components/block-styles.svelte";
|
|
10
10
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
11
11
|
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
@@ -91,32 +91,8 @@ let childrenContext = writable($context);
|
|
|
91
91
|
<BlockStyles {block} context={$context} />
|
|
92
92
|
|
|
93
93
|
{#if !blockComponent?.()?.noWrap}
|
|
94
|
-
{#if
|
|
95
|
-
<BlockWrapper
|
|
96
|
-
Wrapper={Tag()}
|
|
97
|
-
block={processedBlock()}
|
|
98
|
-
{context}
|
|
99
|
-
hasChildren={false}
|
|
100
|
-
/>
|
|
101
|
-
{/if}
|
|
102
|
-
|
|
103
|
-
{#if !isEmptyHtmlElement(Tag()) && repeatItem()}
|
|
104
|
-
{#each repeatItem() as data, index (index)}
|
|
105
|
-
<RepeatedBlock
|
|
106
|
-
repeatContext={data.context}
|
|
107
|
-
block={data.block}
|
|
108
|
-
{registeredComponents}
|
|
109
|
-
/>
|
|
110
|
-
{/each}
|
|
111
|
-
{/if}
|
|
112
|
-
|
|
113
|
-
{#if !isEmptyHtmlElement(Tag()) && !repeatItem()}
|
|
114
|
-
<BlockWrapper
|
|
115
|
-
Wrapper={Tag()}
|
|
116
|
-
block={processedBlock()}
|
|
117
|
-
{context}
|
|
118
|
-
hasChildren={true}
|
|
119
|
-
>
|
|
94
|
+
{#if !repeatItem()}
|
|
95
|
+
<BlockWrapper Wrapper={Tag()} block={processedBlock()} {context}>
|
|
120
96
|
<ComponentRef
|
|
121
97
|
componentRef={componentRefProps().componentRef}
|
|
122
98
|
componentOptions={componentRefProps().componentOptions}
|
|
@@ -136,6 +112,14 @@ let childrenContext = writable($context);
|
|
|
136
112
|
/>
|
|
137
113
|
{/each}
|
|
138
114
|
</BlockWrapper>
|
|
115
|
+
{:else}
|
|
116
|
+
{#each repeatItem() as data, index (index)}
|
|
117
|
+
<RepeatedBlock
|
|
118
|
+
repeatContext={data.context}
|
|
119
|
+
block={data.block}
|
|
120
|
+
{registeredComponents}
|
|
121
|
+
/>
|
|
122
|
+
{/each}
|
|
139
123
|
{/if}
|
|
140
124
|
{:else}
|
|
141
125
|
<ComponentRef
|
|
@@ -1,56 +1,30 @@
|
|
|
1
1
|
<script context="module">/**
|
|
2
|
-
* This import is used by the Svelte SDK. Do not remove.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
2
|
* This component renders a block's wrapper HTML element (from the block's `tagName` property).
|
|
6
|
-
* It reuses the exact same logic as the `InteractiveElement` component, but we need to have 2 separate components for
|
|
7
|
-
* Svelte's sake, as it needs to know at compile-time whether to use:
|
|
8
|
-
* - `<svelte:element>` (for HTML element) or
|
|
9
|
-
* - `<svelte:component>` (for custom components)
|
|
10
3
|
*/
|
|
11
4
|
</script>
|
|
12
5
|
|
|
13
6
|
<script>import { getBlockActions } from "../../../functions/get-block-actions.js";
|
|
14
7
|
import { getBlockProperties } from "../../../functions/get-block-properties.js";
|
|
15
|
-
import
|
|
8
|
+
import DynamicRenderer from "../../dynamic-renderer/dynamic-renderer.svelte";
|
|
16
9
|
export let Wrapper;
|
|
17
10
|
export let block;
|
|
18
11
|
export let context;
|
|
19
|
-
export let hasChildren;
|
|
20
12
|
</script>
|
|
21
13
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
</svelte:element>
|
|
40
|
-
{:else}
|
|
41
|
-
<svelte:element
|
|
42
|
-
this={Wrapper}
|
|
43
|
-
{...getBlockProperties({
|
|
44
|
-
block: block,
|
|
45
|
-
context: $context,
|
|
46
|
-
})}
|
|
47
|
-
use:setAttrs={getBlockActions({
|
|
48
|
-
block: block,
|
|
49
|
-
rootState: $context.rootState,
|
|
50
|
-
rootSetState: $context.rootSetState,
|
|
51
|
-
localState: $context.localState,
|
|
52
|
-
context: $context.context,
|
|
53
|
-
stripPrefix: true,
|
|
54
|
-
})}
|
|
55
|
-
/>
|
|
56
|
-
{/if}
|
|
14
|
+
<DynamicRenderer
|
|
15
|
+
TagName={Wrapper}
|
|
16
|
+
attributes={getBlockProperties({
|
|
17
|
+
block: block,
|
|
18
|
+
context: $context,
|
|
19
|
+
})}
|
|
20
|
+
actionAttributes={getBlockActions({
|
|
21
|
+
block: block,
|
|
22
|
+
rootState: $context.rootState,
|
|
23
|
+
rootSetState: $context.rootSetState,
|
|
24
|
+
localState: $context.localState,
|
|
25
|
+
context: $context.context,
|
|
26
|
+
stripPrefix: true,
|
|
27
|
+
})}
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</DynamicRenderer>
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
/**
|
|
3
|
-
* This import is used by the Svelte SDK. Do not remove.
|
|
4
|
-
*/
|
|
5
2
|
type BlockWrapperProps = {
|
|
6
3
|
Wrapper: string;
|
|
7
4
|
block: BuilderBlock;
|
|
8
5
|
context: Writable<BuilderContextInterface>;
|
|
9
|
-
hasChildren: boolean;
|
|
10
6
|
};
|
|
11
7
|
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
12
8
|
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
@@ -17,7 +13,6 @@ declare const __propDef: {
|
|
|
17
13
|
Wrapper: PropsWithChildren<BlockWrapperProps>["Wrapper"];
|
|
18
14
|
block: PropsWithChildren<BlockWrapperProps>["block"];
|
|
19
15
|
context: PropsWithChildren<BlockWrapperProps>["context"];
|
|
20
|
-
hasChildren: PropsWithChildren<BlockWrapperProps>["hasChildren"];
|
|
21
16
|
};
|
|
22
17
|
events: {
|
|
23
18
|
[evt: string]: CustomEvent<any>;
|
|
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index.js";
|
|
|
8
8
|
import { fetch } from "../../../functions/get-fetch.js";
|
|
9
9
|
import { isBrowser } from "../../../functions/is-browser.js";
|
|
10
10
|
import { isEditing } from "../../../functions/is-editing.js";
|
|
11
|
+
import { isFromTrustedHost } from "../../../functions/is-from-trusted-host.js";
|
|
11
12
|
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
12
13
|
import { createRegisterComponentMessage } from "../../../functions/register-component.js";
|
|
13
14
|
import { _track } from "../../../functions/track/index.js";
|
|
@@ -18,6 +19,7 @@ import "../../../helpers/preview-lru-cache/set.js";
|
|
|
18
19
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
|
|
19
20
|
export let builderContextSignal;
|
|
20
21
|
export let contentWrapper = undefined;
|
|
22
|
+
export let trustedHosts = undefined;
|
|
21
23
|
export let model = undefined;
|
|
22
24
|
export let context = undefined;
|
|
23
25
|
export let canTrack = undefined;
|
|
@@ -59,6 +61,9 @@ function mergeNewContent(newContent) {
|
|
|
59
61
|
$builderContextSignal.content = newContentValue;
|
|
60
62
|
}
|
|
61
63
|
function processMessage(event) {
|
|
64
|
+
if (!isFromTrustedHost(trustedHosts, event)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
62
67
|
const { data } = event;
|
|
63
68
|
if (data) {
|
|
64
69
|
switch (data.type) {
|
|
@@ -193,6 +198,11 @@ function elementRef_onIniteditingbldr(event) {
|
|
|
193
198
|
enrich: enrich,
|
|
194
199
|
}
|
|
195
200
|
: {}),
|
|
201
|
+
...(trustedHosts
|
|
202
|
+
? {
|
|
203
|
+
trustedHosts: trustedHosts,
|
|
204
|
+
}
|
|
205
|
+
: {}),
|
|
196
206
|
});
|
|
197
207
|
Object.values($builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
198
208
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
@@ -11,6 +11,7 @@ declare const __propDef: {
|
|
|
11
11
|
props: {
|
|
12
12
|
builderContextSignal: BuilderEditorProps["builderContextSignal"];
|
|
13
13
|
contentWrapper?: BuilderEditorProps["contentWrapper"];
|
|
14
|
+
trustedHosts?: BuilderEditorProps["trustedHosts"];
|
|
14
15
|
model?: BuilderEditorProps["model"];
|
|
15
16
|
context?: BuilderEditorProps["context"];
|
|
16
17
|
canTrack?: BuilderEditorProps["canTrack"];
|
|
@@ -27,6 +27,7 @@ export let enrich = undefined;
|
|
|
27
27
|
export let showContent;
|
|
28
28
|
export let contentWrapper = undefined;
|
|
29
29
|
export let contentWrapperProps = undefined;
|
|
30
|
+
export let trustedHosts = undefined;
|
|
30
31
|
export let isSsrAbTest;
|
|
31
32
|
function contentSetState(newRootState) {
|
|
32
33
|
$builderContextSignal.rootState = newRootState;
|
|
@@ -104,6 +105,7 @@ setContext(ComponentsContext.key, {
|
|
|
104
105
|
{builderContextSignal}
|
|
105
106
|
{contentWrapper}
|
|
106
107
|
{contentWrapperProps}
|
|
108
|
+
{trustedHosts}
|
|
107
109
|
{...{}}
|
|
108
110
|
>
|
|
109
111
|
{#if isSsrAbTest}
|
|
@@ -18,6 +18,7 @@ declare const __propDef: {
|
|
|
18
18
|
showContent: ContentProps["showContent"];
|
|
19
19
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
20
20
|
contentWrapperProps?: ContentProps["contentWrapperProps"];
|
|
21
|
+
trustedHosts?: ContentProps["trustedHosts"];
|
|
21
22
|
isSsrAbTest: ContentProps["isSsrAbTest"];
|
|
22
23
|
};
|
|
23
24
|
events: {
|
|
@@ -24,6 +24,7 @@ export let blocksWrapper = undefined;
|
|
|
24
24
|
export let blocksWrapperProps = undefined;
|
|
25
25
|
export let contentWrapper = undefined;
|
|
26
26
|
export let contentWrapperProps = undefined;
|
|
27
|
+
export let trustedHosts = undefined;
|
|
27
28
|
$: updateCookieAndStylesScriptStr = () => {
|
|
28
29
|
return getUpdateCookieAndStylesScript(getVariants(content).map((value) => ({
|
|
29
30
|
id: value.testVariationId,
|
|
@@ -89,6 +90,7 @@ onMount(() => {
|
|
|
89
90
|
{blocksWrapperProps}
|
|
90
91
|
{contentWrapper}
|
|
91
92
|
{contentWrapperProps}
|
|
93
|
+
{trustedHosts}
|
|
92
94
|
/>
|
|
93
95
|
{/each}
|
|
94
96
|
{/if}
|
|
@@ -112,4 +114,5 @@ onMount(() => {
|
|
|
112
114
|
{blocksWrapperProps}
|
|
113
115
|
{contentWrapper}
|
|
114
116
|
{contentWrapperProps}
|
|
117
|
+
{trustedHosts}
|
|
115
118
|
/>
|
|
@@ -24,6 +24,7 @@ declare const __propDef: {
|
|
|
24
24
|
blocksWrapperProps?: VariantsProviderProps["blocksWrapperProps"];
|
|
25
25
|
contentWrapper?: VariantsProviderProps["contentWrapper"];
|
|
26
26
|
contentWrapperProps?: VariantsProviderProps["contentWrapperProps"];
|
|
27
|
+
trustedHosts?: VariantsProviderProps["trustedHosts"];
|
|
27
28
|
};
|
|
28
29
|
events: {
|
|
29
30
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isEmptyElement: (tagName: any) => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
|
3
|
+
*/
|
|
4
|
+
const EMPTY_HTML_ELEMENTS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
|
|
5
|
+
export const isEmptyElement = (tagName) => {
|
|
6
|
+
return typeof tagName === 'string' && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
7
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script>import { isEmptyElement } from "./dynamic-renderer.helpers.js";
|
|
2
|
+
import { setAttrs } from "../../blocks/helpers.js";
|
|
3
|
+
export let attributes;
|
|
4
|
+
export let TagName;
|
|
5
|
+
export let actionAttributes;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#if !isEmptyElement(TagName)}
|
|
9
|
+
{#if typeof TagName === "string"}
|
|
10
|
+
<svelte:element
|
|
11
|
+
this={TagName}
|
|
12
|
+
{...attributes}
|
|
13
|
+
use:setAttrs={actionAttributes}
|
|
14
|
+
>
|
|
15
|
+
<slot />
|
|
16
|
+
</svelte:element>
|
|
17
|
+
{:else}
|
|
18
|
+
<svelte:component this={TagName} {...attributes} {...actionAttributes}>
|
|
19
|
+
<slot />
|
|
20
|
+
</svelte:component>
|
|
21
|
+
{/if}
|
|
22
|
+
{:else}
|
|
23
|
+
<svelte:element
|
|
24
|
+
this={TagName}
|
|
25
|
+
{...attributes}
|
|
26
|
+
use:setAttrs={actionAttributes}
|
|
27
|
+
/>
|
|
28
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { PropsWithChildren } from "../../types/typescript.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
attributes: any;
|
|
6
|
+
TagName: any;
|
|
7
|
+
actionAttributes: any;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type DynamicRendererProps = typeof __propDef.props;
|
|
17
|
+
export type DynamicRendererEvents = typeof __propDef.events;
|
|
18
|
+
export type DynamicRendererSlots = typeof __propDef.slots;
|
|
19
|
+
export default class DynamicRenderer extends SvelteComponent<DynamicRendererProps, DynamicRendererEvents, DynamicRendererSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -14,6 +14,8 @@ import { componentInfo as imgComponentInfo } from '../blocks/img/component-info.
|
|
|
14
14
|
import { default as Img } from '../blocks/img/img.svelte';
|
|
15
15
|
import { componentInfo as sectionComponentInfo } from '../blocks/section/component-info.js';
|
|
16
16
|
import { default as Section } from '../blocks/section/section.svelte';
|
|
17
|
+
import { componentInfo as slotComponentInfo } from '../blocks/slot/component-info.js';
|
|
18
|
+
import { default as Slot } from '../blocks/slot/slot.svelte';
|
|
17
19
|
import { componentInfo as symbolComponentInfo } from '../blocks/symbol/component-info.js';
|
|
18
20
|
import { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
19
21
|
import { componentInfo as textComponentInfo } from '../blocks/text/component-info.js';
|
|
@@ -57,4 +59,7 @@ export const getDefaultRegisteredComponents = () => [{
|
|
|
57
59
|
}, {
|
|
58
60
|
component: Video,
|
|
59
61
|
...videoComponentInfo
|
|
62
|
+
}, {
|
|
63
|
+
component: Slot,
|
|
64
|
+
...slotComponentInfo
|
|
60
65
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.12.
|
|
1
|
+
export declare const SDK_VERSION = "0.12.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.12.
|
|
1
|
+
export const SDK_VERSION = "0.12.2";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
|
|
2
|
+
export function isFromTrustedHost(trustedHosts, e) {
|
|
3
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
4
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SDK_VERSION } from '../constants/sdk-version.js';
|
|
2
2
|
import { TARGET } from '../constants/target.js';
|
|
3
3
|
import { isBrowser } from '../functions/is-browser.js';
|
|
4
|
+
import { isFromTrustedHost } from '../functions/is-from-trusted-host.js';
|
|
4
5
|
import { register } from '../functions/register.js';
|
|
5
6
|
export const registerInsertMenu = () => {
|
|
6
7
|
register('insertMenu', {
|
|
@@ -50,7 +51,11 @@ export const setupBrowserForEditing = (options = {}) => {
|
|
|
50
51
|
options
|
|
51
52
|
}
|
|
52
53
|
}, '*');
|
|
53
|
-
window.addEventListener('message', (
|
|
54
|
+
window.addEventListener('message', (event) => {
|
|
55
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { data } = event;
|
|
54
59
|
if (!data?.type) {
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const componentInfo = {
|
|
2
|
+
name: 'Slot',
|
|
3
|
+
isRSC: true,
|
|
4
|
+
description: 'Allow child blocks to be inserted into this content when used as a Symbol',
|
|
5
|
+
docsLink: 'https://www.builder.io/c/docs/symbols-with-blocks',
|
|
6
|
+
image: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56',
|
|
7
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
8
|
+
inputs: [{
|
|
9
|
+
name: 'name',
|
|
10
|
+
type: 'string',
|
|
11
|
+
required: true,
|
|
12
|
+
defaultValue: 'children'
|
|
13
|
+
}]
|
|
14
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import Blocks from "../../components/blocks/blocks.svelte";
|
|
4
|
+
import "../../functions/deopt.js";
|
|
5
|
+
export let builderContext;
|
|
6
|
+
export let name;
|
|
7
|
+
function mitosis_styling(node, vars) {
|
|
8
|
+
Object.entries(vars || {}).forEach(([p, v]) => {
|
|
9
|
+
if (p.startsWith("--")) {
|
|
10
|
+
node.style.setProperty(p, v);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
node.style[p] = v;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
use:mitosis_styling={{
|
|
21
|
+
pointerEvents: "auto",
|
|
22
|
+
}}
|
|
23
|
+
{...!$builderContext.context?.symbolId && {
|
|
24
|
+
"builder-slot": name,
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<Blocks
|
|
28
|
+
parent={$builderContext.context?.symbolId}
|
|
29
|
+
path={`symbol.data.${name}`}
|
|
30
|
+
context={builderContext}
|
|
31
|
+
blocks={$builderContext.rootState?.[name]}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
export interface DropzoneProps {
|
|
3
|
+
name: string;
|
|
4
|
+
builderBlock: BuilderBlock;
|
|
5
|
+
builderContext: Writable<BuilderContextInterface>;
|
|
6
|
+
attributes: any;
|
|
7
|
+
}
|
|
8
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
9
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
10
|
+
import type { Writable } from "svelte/store";
|
|
11
|
+
declare const __propDef: {
|
|
12
|
+
props: {
|
|
13
|
+
builderContext: DropzoneProps["builderContext"];
|
|
14
|
+
name: DropzoneProps["name"];
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
};
|
|
21
|
+
export type SlotProps = typeof __propDef.props;
|
|
22
|
+
export type SlotEvents = typeof __propDef.events;
|
|
23
|
+
export type SlotSlots = typeof __propDef.slots;
|
|
24
|
+
export default class Slot extends SvelteComponent<SlotProps, SlotEvents, SlotSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -8,6 +8,7 @@ export let attributes = undefined;
|
|
|
8
8
|
export let symbol = undefined;
|
|
9
9
|
export let dynamic = undefined;
|
|
10
10
|
export let builderContext;
|
|
11
|
+
export let builderBlock;
|
|
11
12
|
export let builderComponents;
|
|
12
13
|
function setContent() {
|
|
13
14
|
if (contentToUse)
|
|
@@ -51,7 +52,10 @@ $: onUpdateFn_0(...[symbol]);
|
|
|
51
52
|
__isNestedRender={true}
|
|
52
53
|
apiVersion={$builderContext.apiVersion}
|
|
53
54
|
apiKey={$builderContext.apiKey}
|
|
54
|
-
context={
|
|
55
|
+
context={{
|
|
56
|
+
...$builderContext.context,
|
|
57
|
+
symbolId: builderBlock?.id,
|
|
58
|
+
}}
|
|
55
59
|
customComponents={Object.values(builderComponents)}
|
|
56
60
|
data={{
|
|
57
61
|
...symbol?.data,
|
|
@@ -8,6 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
symbol?: PropsWithBuilderData<SymbolProps>["symbol"];
|
|
9
9
|
dynamic?: PropsWithBuilderData<SymbolProps>["dynamic"];
|
|
10
10
|
builderContext: PropsWithBuilderData<SymbolProps>["builderContext"];
|
|
11
|
+
builderBlock: PropsWithBuilderData<SymbolProps>["builderBlock"];
|
|
11
12
|
builderComponents: PropsWithBuilderData<SymbolProps>["builderComponents"];
|
|
12
13
|
};
|
|
13
14
|
events: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BuilderContextInterface, RegisteredComponents } from '../../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../../types/builder-block.js';
|
|
3
3
|
import type { RepeatData } from './types.js';
|
|
4
|
-
export declare const isEmptyHtmlElement: (tagName: unknown) => boolean;
|
|
5
4
|
export declare const getComponent: ({ block, context, registeredComponents }: {
|
|
6
5
|
block: BuilderBlock;
|
|
7
6
|
context: BuilderContextInterface;
|