@builder.io/sdk-react-native 0.0.1-25 → 0.0.1-26
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 +3 -2
- package/src/blocks/button.js +66 -22
- package/src/blocks/button.lite.tsx +4 -4
- package/src/blocks/columns.js +247 -36
- package/src/blocks/columns.lite.tsx +7 -7
- package/src/blocks/custom-code.js +73 -47
- package/src/blocks/custom-code.lite.tsx +12 -16
- package/src/blocks/embed.js +66 -47
- package/src/blocks/embed.lite.tsx +11 -13
- package/src/blocks/form.js +436 -195
- package/src/blocks/form.lite.tsx +65 -72
- package/src/blocks/fragment.js +16 -8
- package/src/blocks/fragment.lite.tsx +3 -3
- package/src/blocks/image.js +88 -80
- package/src/blocks/image.lite.tsx +14 -15
- package/src/blocks/img.js +45 -28
- package/src/blocks/img.lite.tsx +7 -7
- package/src/blocks/input.js +93 -28
- package/src/blocks/input.lite.tsx +5 -7
- package/src/blocks/raw-text.js +16 -12
- package/src/blocks/raw-text.lite.tsx +3 -3
- package/src/blocks/section.js +66 -23
- package/src/blocks/section.lite.tsx +4 -4
- package/src/blocks/select.js +67 -28
- package/src/blocks/select.lite.tsx +6 -8
- package/src/blocks/submit-button.js +41 -21
- package/src/blocks/submit-button.lite.tsx +3 -3
- package/src/blocks/symbol.js +18 -16
- package/src/blocks/symbol.lite.tsx +5 -5
- package/src/blocks/text.js +29 -27
- package/src/blocks/text.lite.tsx +4 -9
- package/src/blocks/textarea.js +53 -24
- package/src/blocks/textarea.lite.tsx +3 -3
- package/src/blocks/video.js +112 -46
- package/src/blocks/video.lite.tsx +6 -6
- package/src/components/block-styles.js +2 -4
- package/src/components/block-styles.lite.tsx +3 -3
- package/src/components/error-boundary.js +11 -9
- package/src/components/error-boundary.lite.tsx +3 -3
- package/src/components/render-block.js +85 -40
- package/src/components/render-block.lite.tsx +17 -25
- package/src/components/render-blocks.js +56 -32
- package/src/components/render-blocks.lite.tsx +14 -14
- package/src/components/render-content.js +100 -52
- package/src/components/render-content.lite.tsx +32 -41
- package/src/constants/device-sizes.js +8 -11
- package/src/context/builder.context.js +2 -4
- package/src/functions/evaluate.js +17 -9
- package/src/functions/get-block-actions.js +9 -10
- package/src/functions/get-block-component-options.js +11 -10
- package/src/functions/get-block-properties.js +15 -17
- package/src/functions/get-block-styles.js +19 -16
- package/src/functions/get-block-tag.js +2 -4
- package/src/functions/get-content.js +40 -29
- package/src/functions/get-fetch.js +5 -7
- package/src/functions/get-global-this.js +5 -7
- package/src/functions/get-processed-block.js +11 -13
- package/src/functions/get-processed-block.test.js +14 -14
- package/src/functions/get-target.js +2 -4
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +3 -5
- package/src/functions/is-editing.js +3 -5
- package/src/functions/is-iframe.js +2 -4
- package/src/functions/is-previewing.js +4 -6
- package/src/functions/is-react-native.js +2 -4
- package/src/functions/macro-eval.js +2 -5
- package/src/functions/on-change.js +4 -7
- package/src/functions/on-change.test.js +10 -10
- package/src/functions/previewing-model-name.js +3 -5
- package/src/functions/register-component.js +33 -28
- package/src/functions/register.js +8 -10
- package/src/functions/set-editor-settings.js +5 -7
- package/src/functions/set.js +10 -4
- package/src/functions/set.test.js +14 -14
- package/src/functions/track.js +6 -8
- package/src/index.js +20 -18
- package/src/scripts/init-editing.js +64 -40
|
@@ -1,47 +1,71 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet } from
|
|
3
|
-
import { isEditing } from
|
|
4
|
-
import RenderBlock from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { isEditing } from '../functions/is-editing';
|
|
4
|
+
import RenderBlock from './render-block';
|
|
5
5
|
function RenderBlocks(props) {
|
|
6
6
|
var _a, _b;
|
|
7
7
|
function onClick() {
|
|
8
8
|
var _a2, _b2;
|
|
9
9
|
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
10
|
-
(_b2 = window.parent) == null
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
(_b2 = window.parent) == null
|
|
11
|
+
? void 0
|
|
12
|
+
: _b2.postMessage(
|
|
13
|
+
{
|
|
14
|
+
type: 'builder.clickEmptyBlocks',
|
|
15
|
+
data: {
|
|
16
|
+
parentElementId: props.parent,
|
|
17
|
+
dataPath: props.path,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
'*'
|
|
21
|
+
);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
function onMouseEnter() {
|
|
20
25
|
var _a2, _b2;
|
|
21
26
|
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
22
|
-
(_b2 = window.parent) == null
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
(_b2 = window.parent) == null
|
|
28
|
+
? void 0
|
|
29
|
+
: _b2.postMessage(
|
|
30
|
+
{
|
|
31
|
+
type: 'builder.hoverEmptyBlocks',
|
|
32
|
+
data: {
|
|
33
|
+
parentElementId: props.parent,
|
|
34
|
+
dataPath: props.path,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
'*'
|
|
38
|
+
);
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
|
-
return /* @__PURE__ */ React.createElement(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
return /* @__PURE__ */ React.createElement(
|
|
42
|
+
View,
|
|
43
|
+
{
|
|
44
|
+
'builder-path': props.path,
|
|
45
|
+
'builder-parent-id': props.parent,
|
|
46
|
+
onClick: event => onClick,
|
|
47
|
+
onMouseEnter: event => onMouseEnter,
|
|
48
|
+
className:
|
|
49
|
+
'builder-blocks' +
|
|
50
|
+
(!((_a = props.blocks) == null ? void 0 : _a.length) ? ' no-blocks' : ''),
|
|
51
|
+
style: styles.view1,
|
|
52
|
+
},
|
|
53
|
+
props.blocks
|
|
54
|
+
? /* @__PURE__ */ React.createElement(
|
|
55
|
+
React.Fragment,
|
|
56
|
+
null,
|
|
57
|
+
(_b = props.blocks) == null
|
|
58
|
+
? void 0
|
|
59
|
+
: _b.map(block =>
|
|
60
|
+
/* @__PURE__ */ React.createElement(RenderBlock, {
|
|
61
|
+
block,
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
: null
|
|
66
|
+
);
|
|
41
67
|
}
|
|
42
68
|
const styles = StyleSheet.create({
|
|
43
|
-
view1: { display:
|
|
69
|
+
view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
|
|
44
70
|
});
|
|
45
|
-
export {
|
|
46
|
-
RenderBlocks as default
|
|
47
|
-
};
|
|
71
|
+
export { RenderBlocks as default };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import { useState, useContext } from
|
|
4
|
-
import { isEditing } from
|
|
5
|
-
import RenderBlock from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
import { useState, useContext } from 'react';
|
|
4
|
+
import { isEditing } from '../functions/is-editing';
|
|
5
|
+
import RenderBlock from './render-block.lite';
|
|
6
6
|
|
|
7
7
|
export default function RenderBlocks(props) {
|
|
8
8
|
function onClick() {
|
|
9
9
|
if (isEditing() && !props.blocks?.length) {
|
|
10
10
|
window.parent?.postMessage(
|
|
11
11
|
{
|
|
12
|
-
type:
|
|
12
|
+
type: 'builder.clickEmptyBlocks',
|
|
13
13
|
data: {
|
|
14
14
|
parentElementId: props.parent,
|
|
15
15
|
dataPath: props.path,
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
'*'
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -24,13 +24,13 @@ export default function RenderBlocks(props) {
|
|
|
24
24
|
if (isEditing() && !props.blocks?.length) {
|
|
25
25
|
window.parent?.postMessage(
|
|
26
26
|
{
|
|
27
|
-
type:
|
|
27
|
+
type: 'builder.hoverEmptyBlocks',
|
|
28
28
|
data: {
|
|
29
29
|
parentElementId: props.parent,
|
|
30
30
|
dataPath: props.path,
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
'*'
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -39,14 +39,14 @@ export default function RenderBlocks(props) {
|
|
|
39
39
|
<View
|
|
40
40
|
builder-path={props.path}
|
|
41
41
|
builder-parent-id={props.parent}
|
|
42
|
-
onClick={
|
|
43
|
-
onMouseEnter={
|
|
44
|
-
className={
|
|
42
|
+
onClick={event => onClick}
|
|
43
|
+
onMouseEnter={event => onMouseEnter}
|
|
44
|
+
className={'builder-blocks' + (!props.blocks?.length ? ' no-blocks' : '')}
|
|
45
45
|
style={styles.view1}
|
|
46
46
|
>
|
|
47
47
|
{props.blocks ? (
|
|
48
48
|
<>
|
|
49
|
-
{props.blocks?.map(
|
|
49
|
+
{props.blocks?.map(block => (
|
|
50
50
|
<RenderBlock block={block} />
|
|
51
51
|
))}
|
|
52
52
|
</>
|
|
@@ -56,5 +56,5 @@ export default function RenderBlocks(props) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const styles = StyleSheet.create({
|
|
59
|
-
view1: { display:
|
|
59
|
+
view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
|
|
60
60
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, Text } from
|
|
3
|
-
import { useState, useEffect } from
|
|
4
|
-
import { isBrowser } from
|
|
5
|
-
import RenderBlock from
|
|
6
|
-
import BuilderContext from
|
|
7
|
-
import { track } from
|
|
8
|
-
import { isReactNative } from
|
|
9
|
-
import { isEditing } from
|
|
10
|
-
import { isPreviewing } from
|
|
11
|
-
import { previewingModelName } from
|
|
12
|
-
import { getContent } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { isBrowser } from '../functions/is-browser';
|
|
5
|
+
import RenderBlock from './render-block';
|
|
6
|
+
import BuilderContext from '../context/builder.context';
|
|
7
|
+
import { track } from '../functions/track';
|
|
8
|
+
import { isReactNative } from '../functions/is-react-native';
|
|
9
|
+
import { isEditing } from '../functions/is-editing';
|
|
10
|
+
import { isPreviewing } from '../functions/is-previewing';
|
|
11
|
+
import { previewingModelName } from '../functions/previewing-model-name';
|
|
12
|
+
import { getContent } from '../functions/get-content';
|
|
13
13
|
function RenderContent(props) {
|
|
14
14
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
15
15
|
function useContent() {
|
|
@@ -20,10 +20,10 @@ function RenderContent(props) {
|
|
|
20
20
|
const [context, setContext] = useState(() => ({}));
|
|
21
21
|
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
22
22
|
function getCssFromFont(font, data) {
|
|
23
|
-
const family = font.family + (font.kind && !font.kind.includes(
|
|
24
|
-
const name = family.split(
|
|
23
|
+
const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
24
|
+
const name = family.split(',')[0];
|
|
25
25
|
const url = font.fileUrl ? font.fileUrl : font.files && font.files.regular;
|
|
26
|
-
let str =
|
|
26
|
+
let str = '';
|
|
27
27
|
if (url && family && name) {
|
|
28
28
|
str += `
|
|
29
29
|
@font-face {
|
|
@@ -56,13 +56,18 @@ function RenderContent(props) {
|
|
|
56
56
|
return str;
|
|
57
57
|
}
|
|
58
58
|
function getFontCss(data) {
|
|
59
|
-
return (
|
|
59
|
+
return (
|
|
60
|
+
((data == null ? void 0 : data.customFonts) &&
|
|
61
|
+
data.customFonts.length &&
|
|
62
|
+
data.customFonts.map(font => this.getCssFromFont(font, data)).join(' ')) ||
|
|
63
|
+
''
|
|
64
|
+
);
|
|
60
65
|
}
|
|
61
66
|
function processMessage(event) {
|
|
62
67
|
const { data } = event;
|
|
63
68
|
if (data) {
|
|
64
69
|
switch (data.type) {
|
|
65
|
-
case
|
|
70
|
+
case 'builder.contentUpdate': {
|
|
66
71
|
const key = data.data.key || data.data.alias || data.data.entry || data.data.modelName;
|
|
67
72
|
const contentData = data.data.data;
|
|
68
73
|
if (key === props.model) {
|
|
@@ -70,7 +75,7 @@ function RenderContent(props) {
|
|
|
70
75
|
}
|
|
71
76
|
break;
|
|
72
77
|
}
|
|
73
|
-
case
|
|
78
|
+
case 'builder.patchUpdates': {
|
|
74
79
|
break;
|
|
75
80
|
}
|
|
76
81
|
}
|
|
@@ -79,30 +84,30 @@ function RenderContent(props) {
|
|
|
79
84
|
useEffect(() => {
|
|
80
85
|
if (isBrowser()) {
|
|
81
86
|
if (isEditing()) {
|
|
82
|
-
window.addEventListener(
|
|
87
|
+
window.addEventListener('message', processMessage);
|
|
83
88
|
}
|
|
84
89
|
if (useContent() && !isEditing()) {
|
|
85
|
-
track(
|
|
86
|
-
contentId: useContent().id
|
|
90
|
+
track('impression', {
|
|
91
|
+
contentId: useContent().id,
|
|
87
92
|
});
|
|
88
93
|
}
|
|
89
94
|
if (isPreviewing()) {
|
|
90
95
|
if (props.model && previewingModelName() === props.model) {
|
|
91
96
|
const options = {};
|
|
92
97
|
const currentUrl = new URL(location.href);
|
|
93
|
-
const apiKey = currentUrl.searchParams.get(
|
|
98
|
+
const apiKey = currentUrl.searchParams.get('apiKey');
|
|
94
99
|
if (apiKey) {
|
|
95
|
-
const builderPrefix =
|
|
100
|
+
const builderPrefix = 'builder.';
|
|
96
101
|
currentUrl.searchParams.forEach((value, key) => {
|
|
97
102
|
if (key.startsWith(builderPrefix)) {
|
|
98
|
-
options[key.replace(builderPrefix,
|
|
103
|
+
options[key.replace(builderPrefix, '')] = value;
|
|
99
104
|
}
|
|
100
105
|
});
|
|
101
106
|
getContent({
|
|
102
107
|
model: props.model,
|
|
103
108
|
apiKey,
|
|
104
|
-
options
|
|
105
|
-
}).then(
|
|
109
|
+
options,
|
|
110
|
+
}).then(content => {
|
|
106
111
|
if (content) {
|
|
107
112
|
setOverrideContent(content);
|
|
108
113
|
}
|
|
@@ -112,32 +117,75 @@ function RenderContent(props) {
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
}, []);
|
|
115
|
-
return /* @__PURE__ */ React.createElement(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
return /* @__PURE__ */ React.createElement(
|
|
121
|
+
BuilderContext.Provider,
|
|
122
|
+
{
|
|
123
|
+
value: {
|
|
124
|
+
get content() {
|
|
125
|
+
return useContent();
|
|
126
|
+
},
|
|
127
|
+
get state() {
|
|
128
|
+
return state;
|
|
129
|
+
},
|
|
130
|
+
get context() {
|
|
131
|
+
return context;
|
|
132
|
+
},
|
|
119
133
|
},
|
|
120
|
-
get state() {
|
|
121
|
-
return state;
|
|
122
|
-
},
|
|
123
|
-
get context() {
|
|
124
|
-
return context;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}, useContent() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
|
|
128
|
-
onClick: (event) => {
|
|
129
|
-
if (!isEditing()) {
|
|
130
|
-
track("click", {
|
|
131
|
-
contentId: useContent().id
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
134
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
useContent()
|
|
136
|
+
? /* @__PURE__ */ React.createElement(
|
|
137
|
+
React.Fragment,
|
|
138
|
+
null,
|
|
139
|
+
/* @__PURE__ */ React.createElement(
|
|
140
|
+
View,
|
|
141
|
+
{
|
|
142
|
+
onClick: event => {
|
|
143
|
+
if (!isEditing()) {
|
|
144
|
+
track('click', {
|
|
145
|
+
contentId: useContent().id,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
'data-builder-content-id':
|
|
150
|
+
(_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.id,
|
|
151
|
+
},
|
|
152
|
+
(((_c = (_b = useContent == null ? void 0 : useContent()) == null ? void 0 : _b.data) ==
|
|
153
|
+
null
|
|
154
|
+
? void 0
|
|
155
|
+
: _c.cssCode) ||
|
|
156
|
+
(((_e =
|
|
157
|
+
(_d = useContent == null ? void 0 : useContent()) == null ? void 0 : _d.data) ==
|
|
158
|
+
null
|
|
159
|
+
? void 0
|
|
160
|
+
: _e.customFonts) &&
|
|
161
|
+
((_g =
|
|
162
|
+
(_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) ==
|
|
163
|
+
null
|
|
164
|
+
? void 0
|
|
165
|
+
: _g.customFonts.length))) &&
|
|
166
|
+
!isReactNative()
|
|
167
|
+
? /* @__PURE__ */ React.createElement(
|
|
168
|
+
View,
|
|
169
|
+
null,
|
|
170
|
+
/* @__PURE__ */ React.createElement(Text, null, useContent().data.cssCode),
|
|
171
|
+
/* @__PURE__ */ React.createElement(Text, null, getFontCss(useContent().data))
|
|
172
|
+
)
|
|
173
|
+
: null,
|
|
174
|
+
(_j =
|
|
175
|
+
(_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) ==
|
|
176
|
+
null
|
|
177
|
+
? void 0
|
|
178
|
+
: _i.blocks) == null
|
|
179
|
+
? void 0
|
|
180
|
+
: _j.map(block =>
|
|
181
|
+
/* @__PURE__ */ React.createElement(RenderBlock, {
|
|
182
|
+
key: block.id,
|
|
183
|
+
block,
|
|
184
|
+
})
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
: null
|
|
189
|
+
);
|
|
140
190
|
}
|
|
141
|
-
export {
|
|
142
|
-
RenderContent as default
|
|
143
|
-
};
|
|
191
|
+
export { RenderContent as default };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import { useState, useContext, useEffect } from
|
|
4
|
-
import { isBrowser } from
|
|
5
|
-
import RenderBlock from
|
|
6
|
-
import BuilderContext from
|
|
7
|
-
import { track } from
|
|
8
|
-
import { ifTarget } from
|
|
9
|
-
import { onChange } from
|
|
10
|
-
import { isReactNative } from
|
|
11
|
-
import { isEditing } from
|
|
12
|
-
import { isPreviewing } from
|
|
13
|
-
import { previewingModelName } from
|
|
14
|
-
import { getContent } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
import { useState, useContext, useEffect } from 'react';
|
|
4
|
+
import { isBrowser } from '../functions/is-browser';
|
|
5
|
+
import RenderBlock from './render-block.lite';
|
|
6
|
+
import BuilderContext from '../context/builder.context.lite';
|
|
7
|
+
import { track } from '../functions/track';
|
|
8
|
+
import { ifTarget } from '../functions/if-target';
|
|
9
|
+
import { onChange } from '../functions/on-change';
|
|
10
|
+
import { isReactNative } from '../functions/is-react-native';
|
|
11
|
+
import { isEditing } from '../functions/is-editing';
|
|
12
|
+
import { isPreviewing } from '../functions/is-previewing';
|
|
13
|
+
import { previewingModelName } from '../functions/previewing-model-name';
|
|
14
|
+
import { getContent } from '../functions/get-content';
|
|
15
15
|
|
|
16
16
|
export default function RenderContent(props) {
|
|
17
17
|
function useContent() {
|
|
@@ -28,12 +28,10 @@ export default function RenderContent(props) {
|
|
|
28
28
|
|
|
29
29
|
function getCssFromFont(font, data) {
|
|
30
30
|
// TODO: compute what font sizes are used and only load those.......
|
|
31
|
-
const family =
|
|
32
|
-
|
|
33
|
-
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
34
|
-
const name = family.split(",")[0];
|
|
31
|
+
const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
32
|
+
const name = family.split(',')[0];
|
|
35
33
|
const url = font.fileUrl ? font.fileUrl : font.files && font.files.regular;
|
|
36
|
-
let str =
|
|
34
|
+
let str = '';
|
|
37
35
|
|
|
38
36
|
if (url && family && name) {
|
|
39
37
|
str += `
|
|
@@ -81,10 +79,8 @@ export default function RenderContent(props) {
|
|
|
81
79
|
return (
|
|
82
80
|
(data?.customFonts &&
|
|
83
81
|
data.customFonts.length &&
|
|
84
|
-
data.customFonts
|
|
85
|
-
|
|
86
|
-
.join(" ")) ||
|
|
87
|
-
""
|
|
82
|
+
data.customFonts.map(font => this.getCssFromFont(font, data)).join(' ')) ||
|
|
83
|
+
''
|
|
88
84
|
);
|
|
89
85
|
}
|
|
90
86
|
|
|
@@ -93,12 +89,8 @@ export default function RenderContent(props) {
|
|
|
93
89
|
|
|
94
90
|
if (data) {
|
|
95
91
|
switch (data.type) {
|
|
96
|
-
case
|
|
97
|
-
const key =
|
|
98
|
-
data.data.key ||
|
|
99
|
-
data.data.alias ||
|
|
100
|
-
data.data.entry ||
|
|
101
|
-
data.data.modelName;
|
|
92
|
+
case 'builder.contentUpdate': {
|
|
93
|
+
const key = data.data.key || data.data.alias || data.data.entry || data.data.modelName;
|
|
102
94
|
const contentData = data.data.data; // oof
|
|
103
95
|
|
|
104
96
|
if (key === props.model) {
|
|
@@ -108,7 +100,7 @@ export default function RenderContent(props) {
|
|
|
108
100
|
break;
|
|
109
101
|
}
|
|
110
102
|
|
|
111
|
-
case
|
|
103
|
+
case 'builder.patchUpdates': {
|
|
112
104
|
// TODO
|
|
113
105
|
break;
|
|
114
106
|
}
|
|
@@ -119,11 +111,11 @@ export default function RenderContent(props) {
|
|
|
119
111
|
useEffect(() => {
|
|
120
112
|
if (isBrowser()) {
|
|
121
113
|
if (isEditing()) {
|
|
122
|
-
window.addEventListener(
|
|
114
|
+
window.addEventListener('message', processMessage);
|
|
123
115
|
}
|
|
124
116
|
|
|
125
117
|
if (useContent() && !isEditing()) {
|
|
126
|
-
track(
|
|
118
|
+
track('impression', {
|
|
127
119
|
contentId: useContent().id,
|
|
128
120
|
});
|
|
129
121
|
}
|
|
@@ -132,13 +124,13 @@ export default function RenderContent(props) {
|
|
|
132
124
|
if (props.model && previewingModelName() === props.model) {
|
|
133
125
|
const options = {};
|
|
134
126
|
const currentUrl = new URL(location.href);
|
|
135
|
-
const apiKey = currentUrl.searchParams.get(
|
|
127
|
+
const apiKey = currentUrl.searchParams.get('apiKey');
|
|
136
128
|
|
|
137
129
|
if (apiKey) {
|
|
138
|
-
const builderPrefix =
|
|
130
|
+
const builderPrefix = 'builder.';
|
|
139
131
|
currentUrl.searchParams.forEach((value, key) => {
|
|
140
132
|
if (key.startsWith(builderPrefix)) {
|
|
141
|
-
options[key.replace(builderPrefix,
|
|
133
|
+
options[key.replace(builderPrefix, '')] = value;
|
|
142
134
|
}
|
|
143
135
|
}); // TODO: need access to API key
|
|
144
136
|
|
|
@@ -146,7 +138,7 @@ export default function RenderContent(props) {
|
|
|
146
138
|
model: props.model,
|
|
147
139
|
apiKey,
|
|
148
140
|
options,
|
|
149
|
-
}).then(
|
|
141
|
+
}).then(content => {
|
|
150
142
|
if (content) {
|
|
151
143
|
setOverrideContent(content);
|
|
152
144
|
}
|
|
@@ -176,9 +168,9 @@ export default function RenderContent(props) {
|
|
|
176
168
|
{useContent() ? (
|
|
177
169
|
<>
|
|
178
170
|
<View
|
|
179
|
-
onClick={
|
|
171
|
+
onClick={event => {
|
|
180
172
|
if (!isEditing()) {
|
|
181
|
-
track(
|
|
173
|
+
track('click', {
|
|
182
174
|
contentId: useContent().id,
|
|
183
175
|
});
|
|
184
176
|
}
|
|
@@ -186,8 +178,7 @@ export default function RenderContent(props) {
|
|
|
186
178
|
data-builder-content-id={useContent?.()?.id}
|
|
187
179
|
>
|
|
188
180
|
{(useContent?.()?.data?.cssCode ||
|
|
189
|
-
(useContent?.()?.data?.customFonts &&
|
|
190
|
-
useContent?.()?.data?.customFonts.length)) &&
|
|
181
|
+
(useContent?.()?.data?.customFonts && useContent?.()?.data?.customFonts.length)) &&
|
|
191
182
|
!isReactNative() ? (
|
|
192
183
|
<View>
|
|
193
184
|
<Text>{useContent().data.cssCode}</Text>
|
|
@@ -196,7 +187,7 @@ export default function RenderContent(props) {
|
|
|
196
187
|
</View>
|
|
197
188
|
) : null}
|
|
198
189
|
|
|
199
|
-
{useContent?.()?.data?.blocks?.map(
|
|
190
|
+
{useContent?.()?.data?.blocks?.map(block => (
|
|
200
191
|
<RenderBlock key={block.id} block={block} />
|
|
201
192
|
))}
|
|
202
193
|
</View>
|