@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import { onDestroy, onMount, setContext
|
|
3
|
+
<script>import { onDestroy, onMount, setContext } from "svelte";
|
|
4
4
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
5
|
import { TARGET } from "../../constants/target.js";
|
|
6
6
|
import { evaluate } from "../../functions/evaluate.js";
|
|
@@ -10,10 +10,10 @@ import { isBrowser } from "../../functions/is-browser.js";
|
|
|
10
10
|
import { isEditing } from "../../functions/is-editing.js";
|
|
11
11
|
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
12
12
|
import { components, createRegisterComponentMessage, } from "../../functions/register-component.js";
|
|
13
|
-
import { _track } from "../../functions/track.js";
|
|
13
|
+
import { _track } from "../../functions/track/index.js";
|
|
14
14
|
import RenderBlocks from "../render-blocks.svelte";
|
|
15
15
|
import RenderContentStyles from "./components/render-styles.svelte";
|
|
16
|
-
import
|
|
16
|
+
import builderContext from "../../context/builder.context.js";
|
|
17
17
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../scripts/init-editing.js";
|
|
18
18
|
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
19
19
|
export let content;
|
|
@@ -25,7 +25,7 @@ export let customComponents;
|
|
|
25
25
|
export let model;
|
|
26
26
|
export let apiKey;
|
|
27
27
|
export let includeRefs;
|
|
28
|
-
setContext(
|
|
28
|
+
setContext(builderContext.key, {
|
|
29
29
|
get content() {
|
|
30
30
|
return useContent();
|
|
31
31
|
},
|
|
@@ -33,13 +33,13 @@ setContext(BuilderContext.key, {
|
|
|
33
33
|
return contentState();
|
|
34
34
|
},
|
|
35
35
|
get context() {
|
|
36
|
-
return contextContext
|
|
36
|
+
return contextContext;
|
|
37
37
|
},
|
|
38
38
|
get apiKey() {
|
|
39
39
|
return apiKey;
|
|
40
40
|
},
|
|
41
41
|
get registeredComponents() {
|
|
42
|
-
return allRegisteredComponents
|
|
42
|
+
return allRegisteredComponents;
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
function processMessage(event) {
|
|
@@ -82,7 +82,7 @@ function evaluateJsCode() {
|
|
|
82
82
|
if (jsCode) {
|
|
83
83
|
evaluate({
|
|
84
84
|
code: jsCode,
|
|
85
|
-
context: contextContext
|
|
85
|
+
context: contextContext,
|
|
86
86
|
state: contentState(),
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -93,7 +93,7 @@ function onClick(_event) {
|
|
|
93
93
|
const contentId = useContent?.()?.id;
|
|
94
94
|
_track({
|
|
95
95
|
type: "click",
|
|
96
|
-
canTrack: canTrackToUse
|
|
96
|
+
canTrack: canTrackToUse,
|
|
97
97
|
contentId,
|
|
98
98
|
apiKey: apiKey,
|
|
99
99
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -103,7 +103,7 @@ function onClick(_event) {
|
|
|
103
103
|
function evalExpression(expression) {
|
|
104
104
|
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
105
105
|
code: group,
|
|
106
|
-
context: contextContext
|
|
106
|
+
context: contextContext,
|
|
107
107
|
state: contentState(),
|
|
108
108
|
}));
|
|
109
109
|
}
|
|
@@ -124,7 +124,7 @@ function handleRequest({ url, key }) {
|
|
|
124
124
|
function runHttpRequests() {
|
|
125
125
|
const requests = useContent?.()?.data?.httpRequests ?? {};
|
|
126
126
|
Object.entries(requests).forEach(([key, url]) => {
|
|
127
|
-
if (url && (!httpReqsData
|
|
127
|
+
if (url && (!httpReqsData[key] || isEditing())) {
|
|
128
128
|
const evaluatedUrl = evalExpression(url);
|
|
129
129
|
handleRequest({
|
|
130
130
|
url: evaluatedUrl,
|
|
@@ -149,7 +149,7 @@ $: useContent = () => {
|
|
|
149
149
|
if (!content && !overrideContent) {
|
|
150
150
|
return undefined;
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
return {
|
|
153
153
|
...content,
|
|
154
154
|
...overrideContent,
|
|
155
155
|
data: {
|
|
@@ -165,10 +165,6 @@ $: useContent = () => {
|
|
|
165
165
|
content?.meta?.breakpoints,
|
|
166
166
|
},
|
|
167
167
|
};
|
|
168
|
-
return mergedContent;
|
|
169
|
-
};
|
|
170
|
-
$: canTrackToUse = () => {
|
|
171
|
-
return checkIsDefined(canTrack) ? canTrack : true;
|
|
172
168
|
};
|
|
173
169
|
$: contentState = () => {
|
|
174
170
|
return {
|
|
@@ -182,29 +178,6 @@ $: contentState = () => {
|
|
|
182
178
|
...overrideState,
|
|
183
179
|
};
|
|
184
180
|
};
|
|
185
|
-
$: contextContext = () => {
|
|
186
|
-
return context || {};
|
|
187
|
-
};
|
|
188
|
-
$: allRegisteredComponents = () => {
|
|
189
|
-
const allComponentsArray = [
|
|
190
|
-
...getDefaultRegisteredComponents(),
|
|
191
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
192
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
193
|
-
// existing usage.
|
|
194
|
-
// This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
|
|
195
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
196
|
-
...components,
|
|
197
|
-
...(customComponents || []),
|
|
198
|
-
];
|
|
199
|
-
const allComponents = allComponentsArray.reduce((acc, curr) => ({
|
|
200
|
-
...acc,
|
|
201
|
-
[curr.name]: curr,
|
|
202
|
-
}), {});
|
|
203
|
-
return allComponents;
|
|
204
|
-
};
|
|
205
|
-
$: httpReqsData = () => {
|
|
206
|
-
return {};
|
|
207
|
-
};
|
|
208
181
|
$: shouldRenderContentStyles = () => {
|
|
209
182
|
return Boolean((useContent?.()?.data?.cssCode ||
|
|
210
183
|
useContent?.()?.data?.customFonts?.length) &&
|
|
@@ -215,7 +188,23 @@ let forceReRenderCount = 0;
|
|
|
215
188
|
let overrideContent = null;
|
|
216
189
|
let update = 0;
|
|
217
190
|
let useBreakpoints = null;
|
|
191
|
+
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
218
192
|
let overrideState = {};
|
|
193
|
+
let contextContext = context || {};
|
|
194
|
+
let allRegisteredComponents = [
|
|
195
|
+
...getDefaultRegisteredComponents(),
|
|
196
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
197
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
198
|
+
// existing usage.
|
|
199
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
200
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
201
|
+
...components,
|
|
202
|
+
...(customComponents || []),
|
|
203
|
+
].reduce((acc, curr) => ({
|
|
204
|
+
...acc,
|
|
205
|
+
[curr.name]: curr,
|
|
206
|
+
}), {});
|
|
207
|
+
let httpReqsData = {};
|
|
219
208
|
onMount(() => {
|
|
220
209
|
if (!apiKey) {
|
|
221
210
|
console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
@@ -236,7 +225,7 @@ onMount(() => {
|
|
|
236
225
|
}
|
|
237
226
|
: {}),
|
|
238
227
|
});
|
|
239
|
-
Object.values(allRegisteredComponents
|
|
228
|
+
Object.values(allRegisteredComponents).forEach((registeredComponent) => {
|
|
240
229
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
241
230
|
window.parent?.postMessage(message, "*");
|
|
242
231
|
});
|
|
@@ -248,7 +237,7 @@ onMount(() => {
|
|
|
248
237
|
const contentId = useContent?.()?.id;
|
|
249
238
|
_track({
|
|
250
239
|
type: "impression",
|
|
251
|
-
canTrack: canTrackToUse
|
|
240
|
+
canTrack: canTrackToUse,
|
|
252
241
|
contentId,
|
|
253
242
|
apiKey: apiKey,
|
|
254
243
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -257,18 +246,28 @@ onMount(() => {
|
|
|
257
246
|
// override normal content in preview mode
|
|
258
247
|
if (isPreviewing()) {
|
|
259
248
|
const searchParams = new URL(location.href).searchParams;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
249
|
+
const searchParamPreview = searchParams.get("builder.preview");
|
|
250
|
+
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
251
|
+
/**
|
|
252
|
+
* Make sure that:
|
|
253
|
+
* - the preview model name is the same as the one we're rendering, since there can be multiple models rendered
|
|
254
|
+
* at the same time, e.g. header/page/footer.
|
|
255
|
+
* - the API key is the same, since we don't want to preview content from other organizations.
|
|
256
|
+
*
|
|
257
|
+
* TO-DO: should we check that the preview item ID is the same as the initial one being rendered? Or would
|
|
258
|
+
* this break scenarios where the item is not published yet?
|
|
259
|
+
*
|
|
260
|
+
* TO-DO: should we only update the state when there is a change?
|
|
261
|
+
**/
|
|
262
|
+
if (searchParamPreview === model && previewApiKey === apiKey) {
|
|
263
|
+
getContent({
|
|
264
|
+
model: model,
|
|
265
|
+
apiKey: apiKey,
|
|
266
|
+
}).then((content) => {
|
|
267
|
+
if (content) {
|
|
268
|
+
overrideContent = content;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
273
|
evaluateJsCode();
|
|
@@ -316,4 +315,4 @@ onDestroy(() => {
|
|
|
316
315
|
key={forceReRenderCount}
|
|
317
316
|
/>
|
|
318
317
|
</div>
|
|
319
|
-
{/if}
|
|
318
|
+
{/if}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TARGET } from '../../constants/target';
|
|
2
|
+
import { isBrowser } from '../is-browser';
|
|
3
|
+
const getLocation = () => {
|
|
4
|
+
if (TARGET === 'reactNative') {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
else if (isBrowser()) {
|
|
8
|
+
const parsedLocation = new URL(location.href);
|
|
9
|
+
// IE11 bug with parsed path being empty string
|
|
10
|
+
// causes issues with our user targeting
|
|
11
|
+
if (parsedLocation.pathname === '') {
|
|
12
|
+
parsedLocation.pathname = '/';
|
|
13
|
+
}
|
|
14
|
+
return parsedLocation;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
console.warn('Cannot get location for tracking in non-browser environment');
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const getUserAgent = () => (typeof navigator === 'object' && navigator.userAgent) || '';
|
|
22
|
+
export const getUserAttributes = () => {
|
|
23
|
+
const userAgent = getUserAgent();
|
|
24
|
+
const isMobile = {
|
|
25
|
+
Android() {
|
|
26
|
+
return userAgent.match(/Android/i);
|
|
27
|
+
},
|
|
28
|
+
BlackBerry() {
|
|
29
|
+
return userAgent.match(/BlackBerry/i);
|
|
30
|
+
},
|
|
31
|
+
iOS() {
|
|
32
|
+
return userAgent.match(/iPhone|iPod/i);
|
|
33
|
+
},
|
|
34
|
+
Opera() {
|
|
35
|
+
return userAgent.match(/Opera Mini/i);
|
|
36
|
+
},
|
|
37
|
+
Windows() {
|
|
38
|
+
return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
|
|
39
|
+
},
|
|
40
|
+
any() {
|
|
41
|
+
return (isMobile.Android() ||
|
|
42
|
+
isMobile.BlackBerry() ||
|
|
43
|
+
isMobile.iOS() ||
|
|
44
|
+
isMobile.Opera() ||
|
|
45
|
+
isMobile.Windows() ||
|
|
46
|
+
TARGET === 'reactNative');
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
50
|
+
const url = getLocation();
|
|
51
|
+
return {
|
|
52
|
+
urlPath: url?.pathname,
|
|
53
|
+
host: url?.host || url?.hostname,
|
|
54
|
+
device: isTablet ? 'tablet' : isMobile.any() ? 'mobile' : 'desktop',
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { CanTrack } from '
|
|
1
|
+
import type { CanTrack } from '../../types/can-track.js';
|
|
2
|
+
import type { Dictionary } from '../../types/typescript.js';
|
|
2
3
|
interface Event {
|
|
3
4
|
/**
|
|
4
5
|
* The type of your event.
|
|
@@ -16,9 +17,9 @@ interface Event {
|
|
|
16
17
|
*/
|
|
17
18
|
ownerId: string;
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* (Optional) metadata that you want to provide with your event.
|
|
20
21
|
*/
|
|
21
|
-
metadata?:
|
|
22
|
+
metadata?: Dictionary<any>;
|
|
22
23
|
/**
|
|
23
24
|
* Session ID of the user. This is provided by the SDK by checking session storage.
|
|
24
25
|
*/
|
|
@@ -34,17 +35,11 @@ interface Event {
|
|
|
34
35
|
[index: string]: any;
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
|
-
declare type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId'> & {
|
|
38
|
+
declare type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId' | 'metadata'> & {
|
|
38
39
|
/**
|
|
39
40
|
* Your organization's API key.
|
|
40
41
|
*/
|
|
41
42
|
apiKey: Event['data']['ownerId'];
|
|
42
|
-
/**
|
|
43
|
-
* (Optional) metadata that you want to provide with your event.
|
|
44
|
-
*/
|
|
45
|
-
metadata?: {
|
|
46
|
-
[index: string]: any;
|
|
47
|
-
};
|
|
48
43
|
/**
|
|
49
44
|
* (Optional) Any additional (non-metadata) properties to add to the event.
|
|
50
45
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { TARGET } from '
|
|
2
|
-
import { getSessionId } from '
|
|
3
|
-
import { getVisitorId } from '
|
|
4
|
-
import { isBrowser } from '
|
|
5
|
-
import { isEditing } from '
|
|
1
|
+
import { TARGET } from '../../constants/target.js';
|
|
2
|
+
import { getSessionId } from '../../helpers/sessionId.js';
|
|
3
|
+
import { getVisitorId } from '../../helpers/visitorId.js';
|
|
4
|
+
import { isBrowser } from '../is-browser.js';
|
|
5
|
+
import { isEditing } from '../is-editing.js';
|
|
6
|
+
import { getUserAttributes } from './helpers.js';
|
|
6
7
|
const getTrackingEventData = async ({ canTrack, }) => {
|
|
7
8
|
if (!canTrack) {
|
|
8
9
|
return { visitorId: undefined, sessionId: undefined };
|
|
@@ -18,8 +19,12 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
18
19
|
type: eventType,
|
|
19
20
|
data: {
|
|
20
21
|
...properties,
|
|
21
|
-
metadata:
|
|
22
|
+
metadata: {
|
|
23
|
+
url: location.href,
|
|
24
|
+
...metadata,
|
|
25
|
+
},
|
|
22
26
|
...(await getTrackingEventData({ canTrack })),
|
|
27
|
+
userAttributes: getUserAttributes(),
|
|
23
28
|
ownerId: apiKey,
|
|
24
29
|
},
|
|
25
30
|
});
|
package/package/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export * from './functions/register.js';
|
|
|
8
8
|
export * from './functions/set-editor-settings.js';
|
|
9
9
|
export * from './functions/get-content/index.js';
|
|
10
10
|
export * from './functions/get-builder-search-params/index.js';
|
|
11
|
-
export { track } from './functions/track';
|
|
11
|
+
export { track } from './functions/track/index.js';
|
|
12
12
|
export type { RegisteredComponent } from './context/types';
|
|
13
13
|
export type { ComponentInfo } from './types/components';
|
package/package/index.js
CHANGED
|
@@ -8,4 +8,4 @@ export * from './functions/register.js';
|
|
|
8
8
|
export * from './functions/set-editor-settings.js';
|
|
9
9
|
export * from './functions/get-content/index.js';
|
|
10
10
|
export * from './functions/get-builder-search-params/index.js';
|
|
11
|
-
export { track } from './functions/track';
|
|
11
|
+
export { track } from './functions/track/index.js';
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
|
-
import { getContext
|
|
8
|
+
import { getContext } from "svelte";
|
|
9
9
|
|
|
10
10
|
import BuilderContext from "../context/builder.context.js";
|
|
11
11
|
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
let builderContext = getContext(BuilderContext.key);
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
|
-
<span use:mitosis_styling={builderContext.inheritedStyles}>{text}</span>
|
|
27
|
+
<span use:mitosis_styling={builderContext.inheritedStyles}>{text}</span>
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
<script lang="ts">
|
|
11
11
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
12
12
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
13
|
-
|
|
14
13
|
const filterAttrs = (attrs, filter) => {
|
|
15
14
|
const validAttr = {};
|
|
16
15
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -20,16 +19,12 @@
|
|
|
20
19
|
});
|
|
21
20
|
return validAttr;
|
|
22
21
|
};
|
|
23
|
-
|
|
24
22
|
const setAttrs = (node, attrs) => {
|
|
25
23
|
const attrKeys = Object.keys(attrs);
|
|
26
|
-
|
|
27
24
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
28
25
|
const teardown = (attr) =>
|
|
29
26
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
30
|
-
|
|
31
27
|
attrKeys.map(setup);
|
|
32
|
-
|
|
33
28
|
return {
|
|
34
29
|
update(attrs) {
|
|
35
30
|
const attrKeys = Object.keys(attrs);
|
|
@@ -72,4 +67,4 @@
|
|
|
72
67
|
.button {
|
|
73
68
|
all: unset;
|
|
74
69
|
}
|
|
75
|
-
</style>
|
|
70
|
+
</style>
|
|
@@ -145,10 +145,10 @@
|
|
|
145
145
|
`;
|
|
146
146
|
};
|
|
147
147
|
$: reactNativeColumnsStyles = () => {
|
|
148
|
-
return columnStyleObjects.columns.small;
|
|
148
|
+
return this.columnStyleObjects.columns.small;
|
|
149
149
|
};
|
|
150
150
|
$: reactNativeColumnStyles = () => {
|
|
151
|
-
return columnStyleObjects.column.small;
|
|
151
|
+
return this.columnStyleObjects.column.small;
|
|
152
152
|
};
|
|
153
153
|
</script>
|
|
154
154
|
|
|
@@ -195,4 +195,4 @@
|
|
|
195
195
|
flex-direction: column;
|
|
196
196
|
align-items: stretch;
|
|
197
197
|
}
|
|
198
|
-
</style>
|
|
198
|
+
</style>
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
|
-
import { afterUpdate } from "svelte";
|
|
9
|
-
|
|
10
8
|
import { isJsScript } from "./helpers.js";
|
|
11
9
|
|
|
12
10
|
export let content: EmbedProps["content"];
|
|
@@ -48,4 +46,4 @@
|
|
|
48
46
|
$: onUpdateFn_0(...[elem, ranInitFn]);
|
|
49
47
|
</script>
|
|
50
48
|
|
|
51
|
-
<div class="builder-embed" bind:this={elem}>{@html content}</div>
|
|
49
|
+
<div class="builder-embed" bind:this={elem}>{@html content}</div>
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
</script>
|
|
59
59
|
|
|
60
60
|
<script lang="ts">
|
|
61
|
-
import { getContext
|
|
61
|
+
import { getContext } from "svelte";
|
|
62
62
|
|
|
63
63
|
import RenderBlock from "../../components/render-block/render-block.svelte";
|
|
64
64
|
import BuilderBlocks from "../../components/render-blocks.svelte";
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
|
|
67
67
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
68
68
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
69
|
-
|
|
70
69
|
const filterAttrs = (attrs, filter) => {
|
|
71
70
|
const validAttr = {};
|
|
72
71
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -76,16 +75,12 @@
|
|
|
76
75
|
});
|
|
77
76
|
return validAttr;
|
|
78
77
|
};
|
|
79
|
-
|
|
80
78
|
const setAttrs = (node, attrs) => {
|
|
81
79
|
const attrKeys = Object.keys(attrs);
|
|
82
|
-
|
|
83
80
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
84
81
|
const teardown = (attr) =>
|
|
85
82
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
86
|
-
|
|
87
83
|
attrKeys.map(setup);
|
|
88
|
-
|
|
89
84
|
return {
|
|
90
85
|
update(attrs) {
|
|
91
86
|
const attrKeys = Object.keys(attrs);
|
|
@@ -364,4 +359,4 @@
|
|
|
364
359
|
color: red;
|
|
365
360
|
text-align: center;
|
|
366
361
|
}
|
|
367
|
-
</style>
|
|
362
|
+
</style>
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
srcset={srcSetToUse()}
|
|
107
107
|
{sizes}
|
|
108
108
|
/>
|
|
109
|
-
<source srcset={srcSetToUse()} />
|
|
110
109
|
</picture>
|
|
111
110
|
|
|
112
111
|
{#if aspectRatio && !(builderBlock?.children?.length && fitContent)}
|
|
@@ -150,4 +149,4 @@
|
|
|
150
149
|
width: 100%;
|
|
151
150
|
height: 100%;
|
|
152
151
|
}
|
|
153
|
-
</style>
|
|
152
|
+
</style>
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
25
25
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
26
|
-
|
|
27
26
|
const filterAttrs = (attrs, filter) => {
|
|
28
27
|
const validAttr = {};
|
|
29
28
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -33,16 +32,12 @@
|
|
|
33
32
|
});
|
|
34
33
|
return validAttr;
|
|
35
34
|
};
|
|
36
|
-
|
|
37
35
|
const setAttrs = (node, attrs) => {
|
|
38
36
|
const attrKeys = Object.keys(attrs);
|
|
39
|
-
|
|
40
37
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
41
38
|
const teardown = (attr) =>
|
|
42
39
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
43
|
-
|
|
44
40
|
attrKeys.map(setup);
|
|
45
|
-
|
|
46
41
|
return {
|
|
47
42
|
update(attrs) {
|
|
48
43
|
const attrKeys = Object.keys(attrs);
|
|
@@ -83,4 +78,4 @@
|
|
|
83
78
|
src={imgSrc || image}
|
|
84
79
|
{...filterAttrs(attributes, isNonEvent)}
|
|
85
80
|
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
86
|
-
/>
|
|
81
|
+
/>
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
17
17
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
18
|
-
|
|
19
18
|
const filterAttrs = (attrs, filter) => {
|
|
20
19
|
const validAttr = {};
|
|
21
20
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -25,16 +24,12 @@
|
|
|
25
24
|
});
|
|
26
25
|
return validAttr;
|
|
27
26
|
};
|
|
28
|
-
|
|
29
27
|
const setAttrs = (node, attrs) => {
|
|
30
28
|
const attrKeys = Object.keys(attrs);
|
|
31
|
-
|
|
32
29
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
33
30
|
const teardown = (attr) =>
|
|
34
31
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
35
|
-
|
|
36
32
|
attrKeys.map(setup);
|
|
37
|
-
|
|
38
33
|
return {
|
|
39
34
|
update(attrs) {
|
|
40
35
|
const attrKeys = Object.keys(attrs);
|
|
@@ -66,4 +61,4 @@
|
|
|
66
61
|
{defaultValue}
|
|
67
62
|
{required}
|
|
68
63
|
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
69
|
-
/>
|
|
64
|
+
/>
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
<script lang="ts">
|
|
11
11
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
12
12
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
13
|
-
|
|
14
13
|
const filterAttrs = (attrs, filter) => {
|
|
15
14
|
const validAttr = {};
|
|
16
15
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -20,16 +19,12 @@
|
|
|
20
19
|
});
|
|
21
20
|
return validAttr;
|
|
22
21
|
};
|
|
23
|
-
|
|
24
22
|
const setAttrs = (node, attrs) => {
|
|
25
23
|
const attrKeys = Object.keys(attrs);
|
|
26
|
-
|
|
27
24
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
28
25
|
const teardown = (attr) =>
|
|
29
26
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
30
|
-
|
|
31
27
|
attrKeys.map(setup);
|
|
32
|
-
|
|
33
28
|
return {
|
|
34
29
|
update(attrs) {
|
|
35
30
|
const attrKeys = Object.keys(attrs);
|
|
@@ -73,4 +68,4 @@
|
|
|
73
68
|
use:setAttrs={filterAttrs(attributes, isEvent)}
|
|
74
69
|
>
|
|
75
70
|
<slot />
|
|
76
|
-
</section>
|
|
71
|
+
</section>
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
18
18
|
const isNonEvent = (attr) => !attr.startsWith("on:");
|
|
19
|
-
|
|
20
19
|
const filterAttrs = (attrs, filter) => {
|
|
21
20
|
const validAttr = {};
|
|
22
21
|
Object.keys(attrs).forEach((attr) => {
|
|
@@ -26,16 +25,12 @@
|
|
|
26
25
|
});
|
|
27
26
|
return validAttr;
|
|
28
27
|
};
|
|
29
|
-
|
|
30
28
|
const setAttrs = (node, attrs) => {
|
|
31
29
|
const attrKeys = Object.keys(attrs);
|
|
32
|
-
|
|
33
30
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
34
31
|
const teardown = (attr) =>
|
|
35
32
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
36
|
-
|
|
37
33
|
attrKeys.map(setup);
|
|
38
|
-
|
|
39
34
|
return {
|
|
40
35
|
update(attrs) {
|
|
41
36
|
const attrKeys = Object.keys(attrs);
|
|
@@ -66,4 +61,4 @@
|
|
|
66
61
|
{#each options as option}
|
|
67
62
|
<option value={option.value}>{option.name || option.value}</option>
|
|
68
63
|
{/each}
|
|
69
|
-
</select>
|
|
64
|
+
</select>
|