@builder.io/sdk-react-native 0.0.1-49 → 0.0.1-51
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/CHANGELOG.md +11 -2
- package/package.json +1 -1
- package/src/blocks/button/button.js +31 -0
- package/src/blocks/{button.lite.tsx → button/button.lite.tsx} +3 -3
- package/src/blocks/button/component-info.js +42 -0
- package/src/blocks/columns/columns.js +59 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +22 -21
- package/src/blocks/columns/component-info.js +218 -0
- package/src/blocks/custom-code/component-info.js +32 -0
- package/src/blocks/custom-code/custom-code.js +50 -0
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +11 -11
- package/src/blocks/embed/component-info.js +25 -0
- package/src/blocks/embed/embed.js +50 -0
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +11 -11
- package/src/blocks/form/component-info.js +263 -0
- package/src/blocks/form/form.js +221 -0
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +51 -50
- package/src/blocks/fragment/component-info.js +12 -0
- package/src/blocks/fragment/fragment.js +8 -0
- package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +2 -2
- package/src/blocks/image/component-info.js +105 -0
- package/src/blocks/image/image.js +41 -0
- package/src/blocks/{image.lite.tsx → image/image.lite.tsx} +11 -11
- package/src/blocks/img/component-info.js +21 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/img/img.lite.tsx +18 -0
- package/src/blocks/input/component-info.js +75 -0
- package/src/blocks/input/input.js +36 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -4
- package/src/blocks/raw-text/component-info.js +17 -0
- package/src/blocks/raw-text/raw-text.js +10 -0
- package/src/blocks/raw-text/raw-text.lite.tsx +6 -0
- package/src/blocks/section/component-info.js +50 -0
- package/src/blocks/section/section.js +31 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -3
- package/src/blocks/select/component-info.js +60 -0
- package/src/blocks/select/select.js +36 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +4 -4
- package/src/blocks/submit-button/component-info.js +29 -0
- package/src/blocks/submit-button/submit-button.js +29 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +2 -2
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +68 -0
- package/src/blocks/symbol/symbol.lite.tsx +60 -0
- package/src/blocks/text/component-info.js +25 -0
- package/src/blocks/text/text.js +65 -0
- package/src/blocks/text/text.lite.tsx +6 -0
- package/src/blocks/textarea/component-info.js +48 -0
- package/src/blocks/textarea/textarea.js +32 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +2 -2
- package/src/blocks/video/component-info.js +107 -0
- package/src/blocks/video/video.js +33 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +5 -5
- package/src/components/error-boundary.js +9 -11
- package/src/components/error-boundary.lite.tsx +2 -2
- package/src/components/render-block/block-styles.js +29 -0
- package/src/components/render-block/block-styles.lite.tsx +35 -0
- package/src/components/render-block/render-block.helpers.js +24 -0
- package/src/components/render-block/render-block.js +116 -0
- package/src/components/render-block/render-block.lite.tsx +139 -0
- package/src/components/render-blocks.js +35 -61
- package/src/components/render-blocks.lite.tsx +11 -11
- package/src/components/render-content/components/render-styles.js +58 -0
- package/src/components/render-content/components/render-styles.lite.tsx +70 -0
- package/src/components/render-content/index.js +5 -0
- package/src/components/render-content/render-content.js +254 -0
- package/src/components/render-content/render-content.lite.tsx +283 -0
- package/src/components/render-inlined-styles.js +18 -0
- package/src/components/render-inlined-styles.lite.tsx +31 -0
- package/src/constants/builder-registered-components.js +27 -0
- package/src/constants/device-sizes.js +11 -8
- package/src/constants/target.js +5 -0
- package/src/context/builder.context.js +11 -3
- package/src/functions/evaluate.js +20 -20
- package/src/functions/event-handler-name.js +3 -1
- package/src/functions/fast-clone.js +5 -0
- package/src/functions/get-block-actions.js +17 -16
- package/src/functions/get-block-component-options.js +9 -16
- package/src/functions/get-block-properties.js +14 -18
- package/src/functions/get-block-styles.js +17 -34
- package/src/functions/get-block-tag.js +4 -2
- package/src/functions/get-builder-search-params/fn.test.js +6 -10
- package/src/functions/get-builder-search-params/index.js +6 -3
- package/src/functions/get-content/fn.test.js +15 -17
- package/src/functions/get-content/index.js +25 -42
- package/src/functions/get-fetch.js +32 -8
- package/src/functions/get-global-this.js +7 -5
- package/src/functions/get-processed-block.js +13 -17
- package/src/functions/get-processed-block.test.js +16 -27
- package/src/functions/if-target.js +14 -3
- package/src/functions/is-browser.js +4 -2
- package/src/functions/is-editing.js +5 -5
- package/src/functions/is-iframe.js +4 -2
- package/src/functions/is-previewing.js +6 -4
- package/src/functions/is-react-native.js +3 -1
- package/src/functions/macro-eval.js +5 -2
- package/src/functions/on-change.js +7 -4
- package/src/functions/on-change.test.js +9 -10
- package/src/functions/previewing-model-name.js +5 -3
- package/src/functions/register-component.js +33 -44
- package/src/functions/register.js +10 -8
- package/src/functions/set-editor-settings.js +7 -5
- package/src/functions/set.js +5 -14
- package/src/functions/set.test.js +13 -14
- package/src/functions/track.js +13 -7
- package/src/functions/transform-block.js +13 -17
- package/src/index-helpers/blocks-exports.js +9 -9
- package/src/index-helpers/top-of-file.js +1 -1
- package/src/index.js +10 -12
- package/src/scripts/init-editing.js +74 -88
- package/src/types/components.js +1 -0
- package/src/types/element.js +1 -0
- package/src/types/targets.js +1 -0
- package/src/types/typescript.js +1 -0
- package/src/blocks/button.js +0 -86
- package/src/blocks/columns.js +0 -293
- package/src/blocks/custom-code.js +0 -83
- package/src/blocks/embed.js +0 -77
- package/src/blocks/form.js +0 -521
- package/src/blocks/fragment.js +0 -21
- package/src/blocks/image.js +0 -165
- package/src/blocks/img.js +0 -64
- package/src/blocks/img.lite.tsx +0 -18
- package/src/blocks/input.js +0 -113
- package/src/blocks/raw-text.js +0 -17
- package/src/blocks/raw-text.lite.tsx +0 -6
- package/src/blocks/section.js +0 -84
- package/src/blocks/select.js +0 -91
- package/src/blocks/submit-button.js +0 -60
- package/src/blocks/symbol.js +0 -20
- package/src/blocks/symbol.lite.tsx +0 -20
- package/src/blocks/text.js +0 -100
- package/src/blocks/text.lite.tsx +0 -6
- package/src/blocks/textarea.js +0 -73
- package/src/blocks/video.js +0 -100
- package/src/components/block-styles.js +0 -5
- package/src/components/block-styles.lite.tsx +0 -6
- package/src/components/render-block.js +0 -164
- package/src/components/render-block.lite.tsx +0 -132
- package/src/components/render-content.js +0 -220
- package/src/components/render-content.lite.tsx +0 -206
- package/src/functions/get-target.js +0 -5
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
test('onChange can observe a shallow change', () => {
|
|
2
|
+
import { onChange } from "./on-change.js";
|
|
3
|
+
test("onChange can observe a shallow change", () => {
|
|
5
4
|
let changeHappend = false;
|
|
6
|
-
const obj = onChange({ foo:
|
|
7
|
-
obj.foo =
|
|
5
|
+
const obj = onChange({ foo: "hi" }, () => changeHappend = true);
|
|
6
|
+
obj.foo = "yo";
|
|
8
7
|
expect(changeHappend).toBe(true);
|
|
9
8
|
});
|
|
10
|
-
test(
|
|
9
|
+
test("onChange can observe a deep change", () => {
|
|
11
10
|
let changeHappend = false;
|
|
12
|
-
const obj = onChange({ foo: { bar:
|
|
13
|
-
obj.foo.bar =
|
|
11
|
+
const obj = onChange({ foo: { bar: "hi" } }, () => changeHappend = true);
|
|
12
|
+
obj.foo.bar = "yo";
|
|
14
13
|
expect(changeHappend).toBe(true);
|
|
15
14
|
});
|
|
16
|
-
test(
|
|
15
|
+
test("Smoke test: callback is not fired if no properties updated", () => {
|
|
17
16
|
let changeHappend = false;
|
|
18
|
-
const obj = onChange({ foo: { bar:
|
|
17
|
+
const obj = onChange({ foo: { bar: "hi" } }, () => changeHappend = true);
|
|
19
18
|
obj.foo.bar;
|
|
20
19
|
expect(changeHappend).toBe(false);
|
|
21
20
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isPreviewing } from
|
|
2
|
+
import { isPreviewing } from "./is-previewing.js";
|
|
3
3
|
function previewingModelName() {
|
|
4
4
|
if (!isPreviewing()) {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
const url = new URL(location.href);
|
|
8
|
-
return url.searchParams.get(
|
|
8
|
+
return url.searchParams.get("builder.preview");
|
|
9
9
|
}
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
previewingModelName
|
|
12
|
+
};
|
|
@@ -5,61 +5,50 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
|
5
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) =>
|
|
9
|
-
key in obj
|
|
10
|
-
? __defProp(obj, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value,
|
|
15
|
-
})
|
|
16
|
-
: (obj[key] = value);
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
9
|
var __spreadValues = (a, b) => {
|
|
18
10
|
for (var prop in b || (b = {}))
|
|
19
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
13
|
if (__getOwnPropSymbols)
|
|
21
14
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
17
|
}
|
|
24
18
|
return a;
|
|
25
19
|
};
|
|
26
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
-
import {
|
|
28
|
-
const components =
|
|
21
|
+
import { fastClone } from "./fast-clone.js";
|
|
22
|
+
const components = [];
|
|
29
23
|
function registerComponent(component, info) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (isBrowser()) {
|
|
33
|
-
const sendInfo = prepareComponentInfoToSend(info);
|
|
34
|
-
(_a = window.parent) == null
|
|
35
|
-
? void 0
|
|
36
|
-
: _a.postMessage(
|
|
37
|
-
{
|
|
38
|
-
type: 'builder.registerComponent',
|
|
39
|
-
data: sendInfo,
|
|
40
|
-
},
|
|
41
|
-
'*'
|
|
42
|
-
);
|
|
43
|
-
}
|
|
24
|
+
components.push({ component, info });
|
|
25
|
+
console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
|
|
44
26
|
return component;
|
|
45
27
|
}
|
|
28
|
+
const createRegisterComponentMessage = ({
|
|
29
|
+
info
|
|
30
|
+
}) => ({
|
|
31
|
+
type: "builder.registerComponent",
|
|
32
|
+
data: prepareComponentInfoToSend(fastClone(info))
|
|
33
|
+
});
|
|
46
34
|
function prepareComponentInfoToSend(info) {
|
|
47
|
-
return __spreadValues(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[key]: `return (${fn.toString()}).apply(this, arguments)`,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
35
|
+
return __spreadValues(__spreadValues({}, info), info.inputs && {
|
|
36
|
+
inputs: info.inputs.map((input) => {
|
|
37
|
+
const keysToConvertFnToString = ["onChange", "showIf"];
|
|
38
|
+
for (const key of keysToConvertFnToString) {
|
|
39
|
+
const fn = input[key];
|
|
40
|
+
if (fn && typeof fn === "function") {
|
|
41
|
+
input = __spreadProps(__spreadValues({}, input), {
|
|
42
|
+
[key]: `return (${fn.toString()}).apply(this, arguments)`
|
|
43
|
+
});
|
|
59
44
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
);
|
|
45
|
+
}
|
|
46
|
+
return input;
|
|
47
|
+
})
|
|
48
|
+
});
|
|
64
49
|
}
|
|
65
|
-
export {
|
|
50
|
+
export {
|
|
51
|
+
components,
|
|
52
|
+
createRegisterComponentMessage,
|
|
53
|
+
registerComponent
|
|
54
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isBrowser } from
|
|
2
|
+
import { isBrowser } from "./is-browser.js";
|
|
3
3
|
const registry = {};
|
|
4
4
|
function register(type, info) {
|
|
5
5
|
let typeList = registry[type];
|
|
@@ -9,20 +9,22 @@ function register(type, info) {
|
|
|
9
9
|
typeList.push(info);
|
|
10
10
|
if (isBrowser()) {
|
|
11
11
|
const message = {
|
|
12
|
-
type:
|
|
12
|
+
type: "builder.register",
|
|
13
13
|
data: {
|
|
14
14
|
type,
|
|
15
|
-
info
|
|
16
|
-
}
|
|
15
|
+
info
|
|
16
|
+
}
|
|
17
17
|
};
|
|
18
18
|
try {
|
|
19
|
-
parent.postMessage(message,
|
|
19
|
+
parent.postMessage(message, "*");
|
|
20
20
|
if (parent !== window) {
|
|
21
|
-
window.postMessage(message,
|
|
21
|
+
window.postMessage(message, "*");
|
|
22
22
|
}
|
|
23
23
|
} catch (err) {
|
|
24
|
-
console.debug(
|
|
24
|
+
console.debug("Could not postmessage", err);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
export {
|
|
28
|
+
export {
|
|
29
|
+
register
|
|
30
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isBrowser } from
|
|
2
|
+
import { isBrowser } from "./is-browser.js";
|
|
3
3
|
const settings = {};
|
|
4
4
|
function setEditorSettings(newSettings) {
|
|
5
5
|
if (isBrowser()) {
|
|
6
6
|
Object.assign(settings, newSettings);
|
|
7
7
|
const message = {
|
|
8
|
-
type:
|
|
9
|
-
data: settings
|
|
8
|
+
type: "builder.settingsChange",
|
|
9
|
+
data: settings
|
|
10
10
|
};
|
|
11
|
-
parent.postMessage(message,
|
|
11
|
+
parent.postMessage(message, "*");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
setEditorSettings
|
|
16
|
+
};
|
package/src/functions/set.js
CHANGED
|
@@ -3,19 +3,10 @@ const set = (obj, _path, value) => {
|
|
|
3
3
|
if (Object(obj) !== obj) {
|
|
4
4
|
return obj;
|
|
5
5
|
}
|
|
6
|
-
const path = Array.isArray(_path)
|
|
7
|
-
|
|
8
|
-
: _path.toString().match(/[^.[\]]+/g);
|
|
9
|
-
path
|
|
10
|
-
.slice(0, -1)
|
|
11
|
-
.reduce(
|
|
12
|
-
(a, c, i) =>
|
|
13
|
-
Object(a[c]) === a[c]
|
|
14
|
-
? a[c]
|
|
15
|
-
: (a[c] =
|
|
16
|
-
Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}),
|
|
17
|
-
obj
|
|
18
|
-
)[path[path.length - 1]] = value;
|
|
6
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
7
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
19
8
|
return obj;
|
|
20
9
|
};
|
|
21
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
set
|
|
12
|
+
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
expect(obj.foo).toBe('baz');
|
|
2
|
+
import { set } from "./set.js";
|
|
3
|
+
test("can shallow set a property", () => {
|
|
4
|
+
const obj = { foo: "bar" };
|
|
5
|
+
set(obj, "foo", "baz");
|
|
6
|
+
expect(obj.foo).toBe("baz");
|
|
8
7
|
});
|
|
9
|
-
test(
|
|
10
|
-
const obj = { foo:
|
|
11
|
-
set(obj,
|
|
12
|
-
expect(obj.foo.bar).toBe(
|
|
8
|
+
test("can deeply set a property", () => {
|
|
9
|
+
const obj = { foo: "bar" };
|
|
10
|
+
set(obj, "foo.bar", "baz");
|
|
11
|
+
expect(obj.foo.bar).toBe("baz");
|
|
13
12
|
});
|
|
14
|
-
test(
|
|
15
|
-
const obj = { foo:
|
|
16
|
-
set(obj,
|
|
17
|
-
expect(obj.foo.bar).toEqual([
|
|
13
|
+
test("can deeply create arrays", () => {
|
|
14
|
+
const obj = { foo: "bar" };
|
|
15
|
+
set(obj, "foo.bar.0", "hi");
|
|
16
|
+
expect(obj.foo.bar).toEqual(["hi"]);
|
|
18
17
|
});
|
package/src/functions/track.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
3
|
+
import { isBrowser } from "./is-browser.js";
|
|
4
|
+
import { isEditing } from "./is-editing.js";
|
|
4
5
|
function track(event, properties) {
|
|
5
|
-
if (
|
|
6
|
+
if (isEditing()) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
6
10
|
return;
|
|
7
11
|
}
|
|
8
12
|
return fetch(`https://builder.io/api/v1/track`, {
|
|
9
|
-
method:
|
|
13
|
+
method: "POST",
|
|
10
14
|
body: JSON.stringify({ events: [{ type: event, data: properties }] }),
|
|
11
15
|
headers: {
|
|
12
|
-
|
|
16
|
+
"content-type": "application/json"
|
|
13
17
|
},
|
|
14
|
-
mode:
|
|
18
|
+
mode: "cors"
|
|
15
19
|
});
|
|
16
20
|
}
|
|
17
|
-
export {
|
|
21
|
+
export {
|
|
22
|
+
track
|
|
23
|
+
};
|
|
@@ -5,38 +5,34 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
|
5
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) =>
|
|
9
|
-
key in obj
|
|
10
|
-
? __defProp(obj, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value,
|
|
15
|
-
})
|
|
16
|
-
: (obj[key] = value);
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
9
|
var __spreadValues = (a, b) => {
|
|
18
10
|
for (var prop in b || (b = {}))
|
|
19
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
13
|
if (__getOwnPropSymbols)
|
|
21
14
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
17
|
}
|
|
24
18
|
return a;
|
|
25
19
|
};
|
|
26
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
21
|
function transformBlock(block) {
|
|
28
|
-
if (block.id.startsWith(
|
|
22
|
+
if (block.id.startsWith("builder-pixel-") && !block.component) {
|
|
29
23
|
return __spreadProps(__spreadValues({}, block), {
|
|
30
24
|
component: {
|
|
31
|
-
name:
|
|
25
|
+
name: "Image",
|
|
32
26
|
options: {
|
|
33
27
|
image: block.properties.src,
|
|
34
28
|
width: 1,
|
|
35
|
-
height: 1
|
|
36
|
-
}
|
|
37
|
-
}
|
|
29
|
+
height: 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
34
|
return block;
|
|
41
35
|
}
|
|
42
|
-
export {
|
|
36
|
+
export {
|
|
37
|
+
transformBlock
|
|
38
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { default as default2 } from
|
|
3
|
-
import { default as default3 } from
|
|
4
|
-
import { default as default4 } from
|
|
5
|
-
import { default as default5 } from
|
|
6
|
-
import { default as default6 } from
|
|
7
|
-
import { default as default7 } from
|
|
8
|
-
import { default as default8 } from
|
|
9
|
-
import { default as default9 } from
|
|
2
|
+
import { default as default2 } from "../blocks/columns/columns.js";
|
|
3
|
+
import { default as default3 } from "../blocks/image/image.js";
|
|
4
|
+
import { default as default4 } from "../blocks/text/text.js";
|
|
5
|
+
import { default as default5 } from "../blocks/symbol/symbol.js";
|
|
6
|
+
import { default as default6 } from "../blocks/button/button.js";
|
|
7
|
+
import { default as default7 } from "../blocks/section/section.js";
|
|
8
|
+
import { default as default8 } from "../blocks/fragment/fragment.js";
|
|
9
|
+
import { default as default9 } from "../components/render-content/render-content.js";
|
|
10
10
|
export {
|
|
11
11
|
default6 as Button,
|
|
12
12
|
default2 as Columns,
|
|
@@ -15,5 +15,5 @@ export {
|
|
|
15
15
|
default9 as RenderContent,
|
|
16
16
|
default7 as Section,
|
|
17
17
|
default5 as Symbol,
|
|
18
|
-
default4 as Text
|
|
18
|
+
default4 as Text
|
|
19
19
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import "react-native-url-polyfill/auto";
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from './functions/get-content';
|
|
13
|
-
export * from './functions/get-builder-search-params';
|
|
2
|
+
import "./index-helpers/top-of-file.js";
|
|
3
|
+
import "./scripts/init-editing.js";
|
|
4
|
+
export * from "./index-helpers/blocks-exports.js";
|
|
5
|
+
export * from "./functions/is-editing.js";
|
|
6
|
+
export * from "./functions/is-previewing.js";
|
|
7
|
+
export * from "./functions/register-component.js";
|
|
8
|
+
export * from "./functions/register.js";
|
|
9
|
+
export * from "./functions/set-editor-settings.js";
|
|
10
|
+
export * from "./functions/get-content/index.js";
|
|
11
|
+
export * from "./functions/get-builder-search-params/index.js";
|
|
@@ -1,95 +1,81 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { isBrowser } from
|
|
4
|
-
import {
|
|
5
|
-
register
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
error
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
: _a2.postMessage(
|
|
56
|
-
{
|
|
57
|
-
type: 'builder.evaluateError',
|
|
58
|
-
data: { id, error: error.message },
|
|
59
|
-
},
|
|
60
|
-
'*'
|
|
61
|
-
);
|
|
62
|
-
} else {
|
|
63
|
-
if (result && typeof result.then === 'function') {
|
|
64
|
-
result
|
|
65
|
-
.then((finalResult) => {
|
|
66
|
-
var _a3;
|
|
67
|
-
(_a3 = window.parent) == null
|
|
68
|
-
? void 0
|
|
69
|
-
: _a3.postMessage(
|
|
70
|
-
{
|
|
71
|
-
type: 'builder.evaluateResult',
|
|
72
|
-
data: { id, result: finalResult },
|
|
73
|
-
},
|
|
74
|
-
'*'
|
|
75
|
-
);
|
|
76
|
-
})
|
|
77
|
-
.catch(console.error);
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
3
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
4
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
5
|
+
import { register } from "../functions/register.js";
|
|
6
|
+
const registerInsertMenu = () => {
|
|
7
|
+
register("insertMenu", {
|
|
8
|
+
name: "_default",
|
|
9
|
+
default: true,
|
|
10
|
+
items: [
|
|
11
|
+
{ name: "Box" },
|
|
12
|
+
{ name: "Text" },
|
|
13
|
+
{ name: "Image" },
|
|
14
|
+
{ name: "Columns" },
|
|
15
|
+
...TARGET === "reactNative" ? [] : [
|
|
16
|
+
{ name: "Core:Section" },
|
|
17
|
+
{ name: "Core:Button" },
|
|
18
|
+
{ name: "Embed" },
|
|
19
|
+
{ name: "Custom Code" }
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const setupBrowserForEditing = () => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (isBrowser()) {
|
|
27
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
28
|
+
type: "builder.sdkInfo",
|
|
29
|
+
data: {
|
|
30
|
+
target: TARGET,
|
|
31
|
+
supportsPatchUpdates: false
|
|
32
|
+
}
|
|
33
|
+
}, "*");
|
|
34
|
+
window.addEventListener("message", ({ data }) => {
|
|
35
|
+
var _a2, _b;
|
|
36
|
+
if (data) {
|
|
37
|
+
switch (data.type) {
|
|
38
|
+
case "builder.evaluate": {
|
|
39
|
+
const text = data.data.text;
|
|
40
|
+
const args = data.data.arguments || [];
|
|
41
|
+
const id = data.data.id;
|
|
42
|
+
const fn = new Function(text);
|
|
43
|
+
let result;
|
|
44
|
+
let error = null;
|
|
45
|
+
try {
|
|
46
|
+
result = fn.apply(null, args);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
error = err;
|
|
49
|
+
}
|
|
50
|
+
if (error) {
|
|
51
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
52
|
+
type: "builder.evaluateError",
|
|
53
|
+
data: { id, error: error.message }
|
|
54
|
+
}, "*");
|
|
78
55
|
} else {
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
if (result && typeof result.then === "function") {
|
|
57
|
+
result.then((finalResult) => {
|
|
58
|
+
var _a3;
|
|
59
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
60
|
+
type: "builder.evaluateResult",
|
|
61
|
+
data: { id, result: finalResult }
|
|
62
|
+
}, "*");
|
|
63
|
+
}).catch(console.error);
|
|
64
|
+
} else {
|
|
65
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
66
|
+
type: "builder.evaluateResult",
|
|
67
|
+
data: { result, id }
|
|
68
|
+
}, "*");
|
|
69
|
+
}
|
|
88
70
|
}
|
|
71
|
+
break;
|
|
89
72
|
}
|
|
90
|
-
break;
|
|
91
73
|
}
|
|
92
74
|
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (isEditing()) {
|
|
79
|
+
registerInsertMenu();
|
|
80
|
+
setupBrowserForEditing();
|
|
95
81
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|