@builder.io/sdk-react 0.0.1-1 → 0.0.1-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/README.md CHANGED
@@ -16,4 +16,4 @@ To check the status of the SDK, look at [these tables](../../README.md#feature-i
16
16
  npm install @builder.io/sdk-react@dev
17
17
  ```
18
18
 
19
- Take a look at [our example repo](/examples/react-native) for how to use this SDK.
19
+ Take a look at [our example repo](/examples/react-v2) for how to use this SDK.
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react",
3
- "description": "Builder.io SDK for React'",
4
- "version": "0.0.1-1",
3
+ "description": "Builder.io SDK for React",
4
+ "version": "0.0.1-2",
5
5
  "main": "src/index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./src/index.js",
10
+ "require": "./src/index.js"
11
+ }
12
+ },
6
13
  "scripts": {
7
14
  "release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
8
15
  },
@@ -24,14 +24,9 @@ function Button(props) {
24
24
  href: props.link,
25
25
  target: props.openLinkInNewTab ? "_blank" : void 0
26
26
  }), props.text)) : /* @__PURE__ */ React.createElement("button", __spreadProps(__spreadValues({}, props.attributes), {
27
- className: "button"
28
- }), props.text)), /* @__PURE__ */ React.createElement("style", {
29
- jsx: true
30
- }, `
31
- .button {
32
- all: unset;
33
- }
34
- `));
27
+ className: "button-7c88bfd8"
28
+ }), props.text)), /* @__PURE__ */ React.createElement("style", null, `.button-7c88bfd8 {
29
+ all: unset; }`));
35
30
  }
36
31
  export {
37
32
  Button as default
@@ -57,10 +57,10 @@ function Columns(props) {
57
57
  };
58
58
  }
59
59
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
60
- className: "builder-columns div",
60
+ className: "builder-columns div-01f6ab8c",
61
61
  style: columnsCssVars()
62
62
  }, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
63
- className: "builder-column div-2",
63
+ className: "builder-column div-01f6ab8c-2",
64
64
  style: __spreadValues({
65
65
  width: getColumnCssWidth(index),
66
66
  marginLeft: `${index === 0 ? 0 : getGutterSize()}px`
@@ -70,40 +70,17 @@ function Columns(props) {
70
70
  blocks: column.blocks,
71
71
  path: `component.options.columns.${index}.blocks`,
72
72
  parent: props.builderBlock.id
73
- })))), /* @__PURE__ */ React.createElement("style", {
74
- jsx: true
75
- }, `
76
- .div {
77
- display: flex;
78
- align-items: stretch;
79
- line-height: normal;
80
- }
81
- @media (max-width: 991px) {
82
- .div {
83
- flex-direction: var(--flex-dir-tablet);
84
- }
85
- }
86
- @media (max-width: 639px) {
87
- .div {
88
- flex-direction: var(--flex-dir);
89
- }
90
- }
91
- .div-2 {
92
- flex-grow: 1;
93
- }
94
- @media (max-width: 991px) {
95
- .div-2 {
96
- width: var(--column-width-tablet) !important;
97
- margin-left: var(--column-margin-left-tablet) !important;
98
- }
99
- }
100
- @media (max-width: 639px) {
101
- .div-2 {
102
- width: var(--column-width) !important;
103
- margin-left: var(--column-margin-left) !important;
104
- }
105
- }
106
- `));
73
+ })))), /* @__PURE__ */ React.createElement("style", null, `.div-01f6ab8c {
74
+ display: flex;
75
+ align-items: stretch;
76
+ line-height: normal; }@media (max-width: 991px) { .div-01f6ab8c {
77
+ flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-01f6ab8c {
78
+ flex-direction: var(--flex-dir); } }.div-01f6ab8c-2 {
79
+ flex-grow: 1; }@media (max-width: 991px) { .div-01f6ab8c-2 {
80
+ width: var(--column-width-tablet) !important;
81
+ margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-01f6ab8c-2 {
82
+ width: var(--column-width) !important;
83
+ margin-left: var(--column-margin-left) !important; } }`));
107
84
  }
108
85
  export {
109
86
  Columns as default
@@ -1,3 +1,4 @@
1
+ import { markSerializable } from "../util";
1
2
  const componentInfo = {
2
3
  name: "Columns",
3
4
  builtIn: true,
@@ -186,7 +187,7 @@ const componentInfo = {
186
187
  ]
187
188
  }
188
189
  ],
189
- onChange(options) {
190
+ onChange: markSerializable((options) => {
190
191
  function clearWidths() {
191
192
  columns.forEach((col) => {
192
193
  col.delete("width");
@@ -210,7 +211,7 @@ const componentInfo = {
210
211
  }
211
212
  }
212
213
  }
213
- }
214
+ })
214
215
  },
215
216
  {
216
217
  name: "space",
@@ -1,3 +1,4 @@
1
+ import { markSerializable } from "../util";
1
2
  const componentInfo = {
2
3
  name: "Embed",
3
4
  static: true,
@@ -9,7 +10,7 @@ const componentInfo = {
9
10
  required: true,
10
11
  defaultValue: "",
11
12
  helperText: "e.g. enter a youtube url, google map, etc",
12
- onChange(options) {
13
+ onChange: markSerializable((options) => {
13
14
  const url = options.get("url");
14
15
  if (url) {
15
16
  options.set("content", "Loading...");
@@ -28,7 +29,7 @@ const componentInfo = {
28
29
  } else {
29
30
  options.delete("content");
30
31
  }
31
- }
32
+ })
32
33
  },
33
34
  {
34
35
  name: "content",
@@ -38,8 +38,9 @@ var __async = (__this, __arguments, generator) => {
38
38
  });
39
39
  };
40
40
  import * as React from "react";
41
- import { useState, useRef } from "react";
41
+ import { useState, useContext, useRef } from "react";
42
42
  import RenderBlock from "../../components/render-block/render-block.js";
43
+ import BuilderBlocks from "../../components/render-blocks.js";
43
44
  import { isEditing } from "../../functions/is-editing.js";
44
45
  function FormComponent(props) {
45
46
  var _a, _b;
@@ -190,6 +191,7 @@ function FormComponent(props) {
190
191
  });
191
192
  }
192
193
  }
194
+ const builderContext = useContext(BuilderContext);
193
195
  return /* @__PURE__ */ React.createElement(React.Fragment, null, " ", /* @__PURE__ */ React.createElement("form", __spreadProps(__spreadValues({}, props.attributes), {
194
196
  validate: props.validate,
195
197
  ref: formRef,
@@ -198,7 +200,8 @@ function FormComponent(props) {
198
200
  name: props.name,
199
201
  onSubmit: (event) => onSubmit(event)
200
202
  }), " ", props.builderBlock && props.builderBlock.children ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
201
- block
203
+ block,
204
+ context: builderContext
202
205
  }))) : null, " ", submissionState() === "error" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
203
206
  dataPath: "errorMessage",
204
207
  blocks: props.errorMessage
@@ -206,19 +209,11 @@ function FormComponent(props) {
206
209
  dataPath: "sendingMessage",
207
210
  blocks: props.sendingMessage
208
211
  })) : null, " ", submissionState() === "error" && responseData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("pre", {
209
- className: "builder-form-error-text pre"
212
+ className: "builder-form-error-text pre-79359d0a"
210
213
  }, " ", JSON.stringify(responseData, null, 2), " ")) : null, " ", submissionState() === "success" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
211
214
  dataPath: "successMessage",
212
215
  blocks: props.successMessage
213
- })) : null, " "), " ", /* @__PURE__ */ React.createElement("style", {
214
- jsx: true
215
- }, `
216
- .pre {
217
- padding: 10px;
218
- color: red;
219
- text-align: center;
220
- }
221
- `), " ");
216
+ })) : null, " "), " ", /* @__PURE__ */ React.createElement("style", null, `.pre-79359d0a { padding: 10px; color: red; text-align: center; }`), " ");
222
217
  }
223
218
  export {
224
219
  FormComponent as default
@@ -1,3 +1,4 @@
1
+ import { markSerializable } from "../util";
1
2
  const componentInfo = {
2
3
  name: "Image",
3
4
  static: true,
@@ -18,7 +19,7 @@ const componentInfo = {
18
19
  allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
19
20
  required: true,
20
21
  defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
21
- onChange(options) {
22
+ onChange: markSerializable((options) => {
22
23
  const DEFAULT_ASPECT_RATIO = 0.7041;
23
24
  options.delete("srcset");
24
25
  options.delete("noWebp");
@@ -64,7 +65,7 @@ const componentInfo = {
64
65
  }
65
66
  });
66
67
  }
67
- }
68
+ })
68
69
  },
69
70
  {
70
71
  name: "backgroundSize",
@@ -28,7 +28,7 @@ function Image(props) {
28
28
  }
29
29
  }
30
30
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
31
- className: "div"
31
+ className: "div-4c804184"
32
32
  }, /* @__PURE__ */ React.createElement("picture", null, webpSrcSet() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("source", {
33
33
  type: "image/webp",
34
34
  srcset: webpSrcSet()
@@ -40,50 +40,39 @@ function Image(props) {
40
40
  objectPosition: props.backgroundSize || "center",
41
41
  objectFit: props.backgroundSize || "cover"
42
42
  },
43
- className: "builder-image" + (props.className ? " " + props.className : "") + " img",
43
+ className: "builder-image" + (props.className ? " " + props.className : "") + " img-4c804184",
44
44
  src: props.image,
45
45
  srcset: srcSetToUse(),
46
46
  sizes: props.sizes
47
47
  }), /* @__PURE__ */ React.createElement("source", {
48
48
  srcset: srcSetToUse()
49
49
  })), props.aspectRatio && !(props.fitContent && ((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length)) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
50
- className: "builder-image-sizer div-2",
50
+ className: "builder-image-sizer div-4c804184-2",
51
51
  style: {
52
52
  paddingTop: props.aspectRatio * 100 + "%"
53
53
  }
54
54
  })) : null, ((_d = (_c = props.builderBlock) == null ? void 0 : _c.children) == null ? void 0 : _d.length) && props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, props.children) : null, !props.fitContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
55
- className: "div-3"
56
- }, props.children)) : null), /* @__PURE__ */ React.createElement("style", {
57
- jsx: true
58
- }, `
59
- .div {
60
- position: relative;
61
- }
62
- .img {
63
- opacity: 1;
64
- transition: opacity 0.2s ease-in-out;
65
- position: absolute;
66
- height: 100%;
67
- width: 100%;
68
- top: 0px;
69
- left: 0px;
70
- }
71
- .div-2 {
72
- width: 100%;
73
- pointer-events: none;
74
- font-size: 0;
75
- }
76
- .div-3 {
77
- display: flex;
78
- flex-direction: column;
79
- align-items: stretch;
80
- position: absolute;
81
- top: 0;
82
- left: 0;
83
- width: 100%;
84
- height: 100%;
85
- }
86
- `));
55
+ className: "div-4c804184-3"
56
+ }, props.children)) : null), /* @__PURE__ */ React.createElement("style", null, `.div-4c804184 {
57
+ position: relative; }.img-4c804184 {
58
+ opacity: 1;
59
+ transition: opacity 0.2s ease-in-out;
60
+ position: absolute;
61
+ height: 100%;
62
+ width: 100%;
63
+ top: 0px;
64
+ left: 0px; }.div-4c804184-2 {
65
+ width: 100%;
66
+ pointer-events: none;
67
+ font-size: 0; }.div-4c804184-3 {
68
+ display: flex;
69
+ flex-direction: column;
70
+ align-items: stretch;
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ height: 100%; }`));
87
76
  }
88
77
  export {
89
78
  Image as default
@@ -27,7 +27,7 @@ function ImgComponent(props) {
27
27
  },
28
28
  key: isEditing() && props.imgSrc || "default-key",
29
29
  alt: props.altText,
30
- src: props.imgSrc
30
+ src: props.imgSrc || props.image
31
31
  }));
32
32
  }
33
33
  export {
@@ -0,0 +1,7 @@
1
+ function markSerializable(fn) {
2
+ fn.__qwik_serializable__ = true;
3
+ return fn;
4
+ }
5
+ export {
6
+ markSerializable
7
+ };
@@ -1,18 +1,16 @@
1
1
  import * as React from "react";
2
- import { useContext } from "react";
2
+ import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
3
3
  import { TARGET } from "../../constants/target.js";
4
- import BuilderContext from "../../context/builder.context";
5
4
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
6
- import RenderInlinedStyles from "../render-inlined-styles.js";
7
5
  import { convertStyleMaptoCSS } from "../../helpers/css.js";
8
- import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
6
+ import RenderInlinedStyles from "../render-inlined-styles.js";
9
7
  function BlockStyles(props) {
10
8
  function useBlock() {
11
9
  return getProcessedBlock({
12
10
  block: props.block,
13
- state: builderContext.state,
14
- context: builderContext.context,
15
- evaluateBindings: true
11
+ state: props.context.state,
12
+ context: props.context.context,
13
+ shouldEvaluateBindings: true
16
14
  });
17
15
  }
18
16
  function css() {
@@ -30,7 +28,6 @@ function BlockStyles(props) {
30
28
  }` : ""}
31
29
  }`;
32
30
  }
33
- const builderContext = useContext(BuilderContext);
34
31
  return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
35
32
  styles: css()
36
33
  })) : null);
@@ -30,8 +30,6 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import * as React from "react";
33
- import { useContext } from "react";
34
- import BuilderContext from "../../context/builder.context";
35
33
  import { getBlockActions } from "../../functions/get-block-actions.js";
36
34
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
37
35
  import { getBlockProperties } from "../../functions/get-block-properties.js";
@@ -49,14 +47,14 @@ function RenderBlock(props) {
49
47
  var _a2;
50
48
  const componentName = (_a2 = getProcessedBlock({
51
49
  block: props.block,
52
- state: builderContext.state,
53
- context: builderContext.context,
54
- evaluateBindings: false
50
+ state: props.context.state,
51
+ context: props.context.context,
52
+ shouldEvaluateBindings: false
55
53
  }).component) == null ? void 0 : _a2.name;
56
54
  if (!componentName) {
57
55
  return null;
58
56
  }
59
- const ref = builderContext.registeredComponents[componentName];
57
+ const ref = props.context.registeredComponents[componentName];
60
58
  if (!ref) {
61
59
  console.warn(`
62
60
  Could not find a registered component named "${componentName}".
@@ -84,16 +82,16 @@ function RenderBlock(props) {
84
82
  function useBlock() {
85
83
  return repeatItemData() ? props.block : getProcessedBlock({
86
84
  block: props.block,
87
- state: builderContext.state,
88
- context: builderContext.context,
89
- evaluateBindings: true
85
+ state: props.context.state,
86
+ context: props.context.context,
87
+ shouldEvaluateBindings: true
90
88
  });
91
89
  }
92
90
  function attributes() {
93
91
  return __spreadProps(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
94
92
  block: useBlock(),
95
- state: builderContext.state,
96
- context: builderContext.context
93
+ state: props.context.state,
94
+ context: props.context.context
97
95
  })), {
98
96
  style: getBlockStyles(useBlock())
99
97
  });
@@ -111,7 +109,8 @@ function RenderBlock(props) {
111
109
  return {
112
110
  blockChildren: children(),
113
111
  componentRef: componentRef(),
114
- componentOptions: componentOptions()
112
+ componentOptions: componentOptions(),
113
+ context: props.context
115
114
  };
116
115
  }
117
116
  function children() {
@@ -129,8 +128,8 @@ function RenderBlock(props) {
129
128
  }
130
129
  const itemsArray = evaluate({
131
130
  code: repeat.collection,
132
- state: builderContext.state,
133
- context: builderContext.context
131
+ state: props.context.state,
132
+ context: props.context.context
134
133
  });
135
134
  if (!Array.isArray(itemsArray)) {
136
135
  return void 0;
@@ -138,8 +137,8 @@ function RenderBlock(props) {
138
137
  const collectionName = repeat.collection.split(".").pop();
139
138
  const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
140
139
  const repeatArray = itemsArray.map((item, index) => ({
141
- context: __spreadProps(__spreadValues({}, builderContext), {
142
- state: __spreadProps(__spreadValues({}, builderContext.state), {
140
+ context: __spreadProps(__spreadValues({}, props.context), {
141
+ state: __spreadProps(__spreadValues({}, props.context.state), {
143
142
  $index: index,
144
143
  $item: item,
145
144
  [itemNameToUse]: item,
@@ -150,7 +149,6 @@ function RenderBlock(props) {
150
149
  }));
151
150
  return repeatArray;
152
151
  }
153
- const builderContext = useContext(BuilderContext);
154
152
  const TagNameRef = tagName();
155
153
  return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, !isEmptyHtmlElement(tagName()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
156
154
  key: index,
@@ -158,11 +156,15 @@ function RenderBlock(props) {
158
156
  block: data.block
159
157
  }))) : null, !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps()))) : null, (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
160
158
  key: "render-block-" + child.id,
161
- block: child
159
+ block: child,
160
+ context: props.context
162
161
  })), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
163
162
  key: "block-style-" + child.id,
164
- block: child
165
- })))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps())));
163
+ block: child,
164
+ context: props.context
165
+ })))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadProps(__spreadValues({}, renderComponentProps()), {
166
+ context: props.context
167
+ })));
166
168
  }
167
169
  export {
168
170
  RenderBlock as default
@@ -22,10 +22,12 @@ function RenderComponent(props) {
22
22
  const ComponentRefRef = props.componentRef;
23
23
  return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({}, props.componentOptions), (_a = props.blockChildren) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
24
24
  key: "render-block-" + child.id,
25
- block: child
25
+ block: child,
26
+ context: props.context
26
27
  })), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
27
28
  key: "block-style-" + child.id,
28
- block: child
29
+ block: child,
30
+ context: props.context
29
31
  })))) : null);
30
32
  }
31
33
  export {
@@ -21,7 +21,8 @@ function RenderRepeatedBlock(props) {
21
21
  }
22
22
  }
23
23
  }, /* @__PURE__ */ React.createElement(RenderBlock, {
24
- block: props.block
24
+ block: props.block,
25
+ context: props.repeatContext
25
26
  }));
26
27
  }
27
28
  export {
@@ -1,4 +1,6 @@
1
1
  import * as React from "react";
2
+ import { useContext } from "react";
3
+ import BuilderContext from "../context/builder.context";
2
4
  import { isEditing } from "../functions/is-editing.js";
3
5
  import BlockStyles from "./render-block/block-styles.js";
4
6
  import RenderBlock from "./render-block/render-block.js";
@@ -32,8 +34,9 @@ function RenderBlocks(props) {
32
34
  }, "*");
33
35
  }
34
36
  }
37
+ const builderContext = useContext(BuilderContext);
35
38
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
36
- className: className() + " div",
39
+ className: className() + " div-452eb7d0",
37
40
  "builder-path": props.path,
38
41
  "builder-parent-id": props.parent,
39
42
  dataSet: {
@@ -43,19 +46,16 @@ function RenderBlocks(props) {
43
46
  onMouseEnter: (event) => onMouseEnter()
44
47
  }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
45
48
  key: "render-block-" + block.id,
46
- block
49
+ block,
50
+ context: builderContext
47
51
  }))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
48
52
  key: "block-style-" + block.id,
49
- block
50
- }))) : null), /* @__PURE__ */ React.createElement("style", {
51
- jsx: true
52
- }, `
53
- .div {
54
- display: flex;
55
- flex-direction: column;
56
- align-items: stretch;
57
- }
58
- `));
53
+ block,
54
+ context: builderContext
55
+ }))) : null), /* @__PURE__ */ React.createElement("style", null, `.div-452eb7d0 {
56
+ display: flex;
57
+ flex-direction: column;
58
+ align-items: stretch; }`));
59
59
  }
60
60
  export {
61
61
  RenderBlocks as default
@@ -38,7 +38,7 @@ var __async = (__this, __arguments, generator) => {
38
38
  });
39
39
  };
40
40
  import * as React from "react";
41
- import { useState, useEffect } from "react";
41
+ import { useState, useRef, useEffect } from "react";
42
42
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
43
43
  import { TARGET } from "../../constants/target.js";
44
44
  import BuilderContext from "../../context/builder.context";
@@ -55,8 +55,14 @@ import {
55
55
  import { track } from "../../functions/track.js";
56
56
  import RenderBlocks from "../render-blocks.js";
57
57
  import RenderContentStyles from "./components/render-styles.js";
58
+ import {
59
+ registerInsertMenu,
60
+ setupBrowserForEditing
61
+ } from "../../scripts/init-editing.js";
58
62
  function RenderContent(props) {
59
63
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
64
+ const elementRef = useRef(null);
65
+ const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
60
66
  function useContent() {
61
67
  var _a2;
62
68
  const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), overrideContent), {
@@ -178,6 +184,9 @@ function RenderContent(props) {
178
184
  useEffect(() => {
179
185
  if (isBrowser()) {
180
186
  if (isEditing()) {
187
+ setForceReRenderCount(forceReRenderCount + 1);
188
+ registerInsertMenu();
189
+ setupBrowserForEditing();
181
190
  Object.values(allRegisteredComponents()).forEach((registeredComponent) => {
182
191
  var _a2;
183
192
  const message = createRegisterComponentMessage(registeredComponent);
@@ -251,13 +260,15 @@ function RenderContent(props) {
251
260
  }
252
261
  }
253
262
  }, useContent() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
263
+ ref: elementRef,
254
264
  onClick: (event) => onClick(event),
255
265
  "builder-content-id": (_e = useContent == null ? void 0 : useContent()) == null ? void 0 : _e.id
256
266
  }, shouldRenderContentStyles() ? /* @__PURE__ */ React.createElement(RenderContentStyles, {
257
267
  cssCode: (_g = (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) == null ? void 0 : _g.cssCode,
258
268
  customFonts: (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) == null ? void 0 : _i.customFonts
259
269
  }) : null, /* @__PURE__ */ React.createElement(RenderBlocks, {
260
- blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks
270
+ blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks,
271
+ key: forceReRenderCount
261
272
  }))) : null);
262
273
  }
263
274
  export {
@@ -32,9 +32,12 @@ import { componentInfo as videoComponentInfo } from "../blocks/video/component-i
32
32
  import { default as Video } from "../blocks/video/video.js";
33
33
  import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info";
34
34
  import { default as embed } from "../blocks/embed/embed.js";
35
+ import { default as Img } from "../blocks/img/img.js";
36
+ import { componentInfo as imgComponentInfo } from "../blocks/img/component-info";
35
37
  const getDefaultRegisteredComponents = () => [
36
38
  __spreadValues({ component: Columns }, columnsComponentInfo),
37
39
  __spreadValues({ component: Image }, imageComponentInfo),
40
+ __spreadValues({ component: Img }, imgComponentInfo),
38
41
  __spreadValues({ component: Text }, textComponentInfo),
39
42
  __spreadValues({ component: Video }, videoComponentInfo),
40
43
  __spreadValues({ component: Symbol }, symbolComponentInfo),
@@ -24,9 +24,9 @@ function getFetch() {
24
24
  const globalFetch = getGlobalThis().fetch;
25
25
  if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
26
26
  const nodeFetch = import("node-fetch").then((d) => d.default);
27
- return nodeFetch;
27
+ return nodeFetch.default || nodeFetch;
28
28
  }
29
- return globalFetch;
29
+ return globalFetch.default || globalFetch;
30
30
  });
31
31
  }
32
32
  export {
@@ -39,13 +39,17 @@ const evaluateBindings = ({
39
39
  }
40
40
  return copied;
41
41
  };
42
- function getProcessedBlock(options) {
43
- const { state, context } = options;
44
- const block = transformBlock(options.block);
45
- if (evaluateBindings) {
46
- return evaluateBindings({ block, state, context });
42
+ function getProcessedBlock({
43
+ block,
44
+ context,
45
+ shouldEvaluateBindings,
46
+ state
47
+ }) {
48
+ const transformedBlock = transformBlock(block);
49
+ if (shouldEvaluateBindings) {
50
+ return evaluateBindings({ block: transformedBlock, state, context });
47
51
  } else {
48
- return block;
52
+ return transformedBlock;
49
53
  }
50
54
  }
51
55
  export {
@@ -21,7 +21,7 @@ test("Can process bindings", () => {
21
21
  block,
22
22
  context: {},
23
23
  state: { test: "hello" },
24
- evaluateBindings: true
24
+ shouldEvaluateBindings: true
25
25
  });
26
26
  expect(processed).not.toEqual(block);
27
27
  expect((_a = processed.properties) == null ? void 0 : _a.foo).toEqual("baz");
@@ -1,6 +1,5 @@
1
1
  import { TARGET } from "../constants/target.js";
2
2
  import { isBrowser } from "../functions/is-browser.js";
3
- import { isEditing } from "../functions/is-editing.js";
4
3
  import { register } from "../functions/register.js";
5
4
  const registerInsertMenu = () => {
6
5
  register("insertMenu", {
@@ -74,7 +73,7 @@ const setupBrowserForEditing = () => {
74
73
  });
75
74
  }
76
75
  };
77
- if (isEditing()) {
78
- registerInsertMenu();
79
- setupBrowserForEditing();
80
- }
76
+ export {
77
+ registerInsertMenu,
78
+ setupBrowserForEditing
79
+ };