@builder.io/sdk-solid 0.0.8-21 → 0.0.8-24

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/blocks/button/button.jsx +6 -1
  3. package/src/blocks/columns/columns.jsx +44 -47
  4. package/src/blocks/columns/component-info.js +3 -2
  5. package/src/blocks/custom-code/custom-code.jsx +34 -37
  6. package/src/blocks/embed/component-info.js +3 -2
  7. package/src/blocks/embed/embed.jsx +28 -31
  8. package/src/blocks/form/form.jsx +172 -173
  9. package/src/blocks/image/component-info.js +3 -2
  10. package/src/blocks/image/image.jsx +26 -29
  11. package/src/blocks/img/img.jsx +1 -1
  12. package/src/blocks/symbol/symbol.jsx +10 -13
  13. package/src/blocks/util.js +7 -0
  14. package/src/blocks/video/video.jsx +19 -23
  15. package/src/components/render-block/block-styles.jsx +22 -27
  16. package/src/components/render-block/render-block.jsx +155 -159
  17. package/src/components/render-block/render-component.jsx +2 -2
  18. package/src/components/render-block/render-repeated-block.jsx +1 -1
  19. package/src/components/render-blocks.jsx +32 -33
  20. package/src/components/render-content/components/render-styles.jsx +38 -41
  21. package/src/components/render-content/render-content.jsx +170 -156
  22. package/src/components/render-inlined-styles.jsx +10 -13
  23. package/src/constants/builder-registered-components.js +3 -0
  24. package/src/functions/get-fetch.js +2 -2
  25. package/src/functions/get-processed-block.js +10 -6
  26. package/src/functions/get-processed-block.test.js +1 -1
  27. package/src/functions/track.js +71 -2
  28. package/src/helpers/cookie.js +59 -0
  29. package/src/helpers/localStorage.js +34 -0
  30. package/src/helpers/nullable.js +4 -0
  31. package/src/helpers/sessionId.js +26 -0
  32. package/src/helpers/time.js +5 -0
  33. package/src/helpers/url.js +10 -0
  34. package/src/helpers/url.test.js +15 -0
  35. package/src/helpers/uuid.js +13 -0
  36. package/src/helpers/visitorId.js +33 -0
  37. package/src/scripts/init-editing.js +4 -5
  38. package/src/types/can-track.js +0 -0
@@ -1,43 +1,38 @@
1
- import { useContext, Show } from "solid-js";
2
- import { createMutable } from "solid-js/store";
1
+ import { Show } from "solid-js";
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.jsx";
7
5
  import { convertStyleMaptoCSS } from "../../helpers/css.js";
8
- import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
6
+ import RenderInlinedStyles from "../render-inlined-styles.jsx";
9
7
 
10
8
  function BlockStyles(props) {
11
- const state = createMutable({
12
- get useBlock() {
13
- return getProcessedBlock({
14
- block: props.block,
15
- state: builderContext.state,
16
- context: builderContext.context,
17
- evaluateBindings: true
18
- });
19
- },
9
+ function useBlock() {
10
+ return getProcessedBlock({
11
+ block: props.block,
12
+ state: props.context.state,
13
+ context: props.context.context,
14
+ shouldEvaluateBindings: true
15
+ });
16
+ }
20
17
 
21
- get css() {
22
- const styles = state.useBlock.responsiveStyles;
23
- const largeStyles = styles?.large;
24
- const mediumStyles = styles?.medium;
25
- const smallStyles = styles?.small;
26
- return `
27
- ${largeStyles ? `.${state.useBlock.id} {${convertStyleMaptoCSS(largeStyles)}}` : ""}
18
+ function css() {
19
+ const styles = useBlock().responsiveStyles;
20
+ const largeStyles = styles?.large;
21
+ const mediumStyles = styles?.medium;
22
+ const smallStyles = styles?.small;
23
+ return `
24
+ ${largeStyles ? `.${useBlock().id} {${convertStyleMaptoCSS(largeStyles)}}` : ""}
28
25
  ${mediumStyles ? `${getMaxWidthQueryForSize("medium")} {
29
- .${state.useBlock.id} {${convertStyleMaptoCSS(mediumStyles)}}
26
+ .${useBlock().id} {${convertStyleMaptoCSS(mediumStyles)}}
30
27
  }` : ""}
31
28
  ${smallStyles ? `${getMaxWidthQueryForSize("small")} {
32
- .${state.useBlock.id} {${convertStyleMaptoCSS(smallStyles)}}
29
+ .${useBlock().id} {${convertStyleMaptoCSS(smallStyles)}}
33
30
  }` : ""}
34
31
  }`;
35
- }
32
+ }
36
33
 
37
- });
38
- const builderContext = useContext(BuilderContext);
39
34
  return <Show when={TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte"}>
40
- <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>
35
+ <RenderInlinedStyles styles={css()}></RenderInlinedStyles>
41
36
  </Show>;
42
37
  }
43
38
 
@@ -1,7 +1,5 @@
1
- import { useContext, Show, For } from "solid-js";
1
+ import { Show, For } from "solid-js";
2
2
  import { Dynamic } from "solid-js/web";
3
- import { createMutable } from "solid-js/store";
4
- import BuilderContext from "../../context/builder.context";
5
3
  import { getBlockActions } from "../../functions/get-block-actions.js";
6
4
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
7
5
  import { getBlockProperties } from "../../functions/get-block-properties.js";
@@ -15,163 +13,161 @@ import RenderComponent from "./render-component.jsx";
15
13
  import RenderRepeatedBlock from "./render-repeated-block.jsx";
16
14
 
17
15
  function RenderBlock(props) {
18
- const state = createMutable({
19
- get component() {
20
- const componentName = getProcessedBlock({
21
- block: props.block,
22
- state: builderContext.state,
23
- context: builderContext.context,
24
- evaluateBindings: false
25
- }).component?.name;
26
-
27
- if (!componentName) {
28
- return null;
29
- }
30
-
31
- const ref = builderContext.registeredComponents[componentName];
32
-
33
- if (!ref) {
34
- // TODO: Public doc page with more info about this message
35
- console.warn(`
16
+ function component() {
17
+ const componentName = getProcessedBlock({
18
+ block: props.block,
19
+ state: props.context.state,
20
+ context: props.context.context,
21
+ shouldEvaluateBindings: false
22
+ }).component?.name;
23
+
24
+ if (!componentName) {
25
+ return null;
26
+ }
27
+
28
+ const ref = props.context.registeredComponents[componentName];
29
+
30
+ if (!ref) {
31
+ // TODO: Public doc page with more info about this message
32
+ console.warn(`
36
33
  Could not find a registered component named "${componentName}".
37
34
  If you registered it, is the file that registered it imported by the file that needs to render it?`);
38
- return undefined;
39
- } else {
40
- return ref;
41
- }
42
- },
43
-
44
- get componentInfo() {
45
- if (state.component) {
46
- const {
47
- component: _,
48
- ...info
49
- } = state.component;
50
- return info;
51
- } else {
52
- return undefined;
53
- }
54
- },
55
-
56
- get componentRef() {
57
- return state.component?.component;
58
- },
59
-
60
- get tagName() {
61
- return getBlockTag(state.useBlock);
62
- },
63
-
64
- get useBlock() {
65
- return state.repeatItemData ? props.block : getProcessedBlock({
66
- block: props.block,
67
- state: builderContext.state,
68
- context: builderContext.context,
69
- evaluateBindings: true
70
- });
71
- },
72
-
73
- get attributes() {
74
- return { ...getBlockProperties(state.useBlock),
75
- ...getBlockActions({
76
- block: state.useBlock,
77
- state: builderContext.state,
78
- context: builderContext.context
79
- }),
80
- style: getBlockStyles(state.useBlock)
81
- };
82
- },
83
-
84
- get shouldWrap() {
85
- return !state.componentInfo?.noWrap;
86
- },
87
-
88
- get componentOptions() {
89
- return { ...getBlockComponentOptions(state.useBlock),
90
-
91
- /**
92
- * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
93
- * they are provided to the component itself directly.
94
- */
95
- ...(state.shouldWrap ? {} : {
96
- attributes: state.attributes
97
- })
98
- };
99
- },
100
-
101
- get renderComponentProps() {
102
- return {
103
- blockChildren: state.children,
104
- componentRef: state.componentRef,
105
- componentOptions: state.componentOptions
106
- };
107
- },
108
-
109
- get children() {
110
- // TO-DO: When should `canHaveChildren` dictate rendering?
111
- // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
112
- // but still receive and need to render children.
113
- // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
114
- return state.useBlock.children ?? [];
115
- },
116
-
117
- get childrenWithoutParentComponent() {
118
- /**
119
- * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
120
- * we render them outside of `componentRef`.
121
- * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
122
- * blocks, and the children will be repeated within those blocks.
123
- */
124
- const shouldRenderChildrenOutsideRef = !state.componentRef && !state.repeatItemData;
125
- return shouldRenderChildrenOutsideRef ? state.children : [];
126
- },
35
+ return undefined;
36
+ } else {
37
+ return ref;
38
+ }
39
+ }
40
+
41
+ function componentInfo() {
42
+ if (component()) {
43
+ const {
44
+ component: _,
45
+ ...info
46
+ } = component();
47
+ return info;
48
+ } else {
49
+ return undefined;
50
+ }
51
+ }
52
+
53
+ function componentRef() {
54
+ return component()?.component;
55
+ }
56
+
57
+ function tagName() {
58
+ return getBlockTag(useBlock());
59
+ }
60
+
61
+ function useBlock() {
62
+ return repeatItemData() ? props.block : getProcessedBlock({
63
+ block: props.block,
64
+ state: props.context.state,
65
+ context: props.context.context,
66
+ shouldEvaluateBindings: true
67
+ });
68
+ }
69
+
70
+ function attributes() {
71
+ return { ...getBlockProperties(useBlock()),
72
+ ...getBlockActions({
73
+ block: useBlock(),
74
+ state: props.context.state,
75
+ context: props.context.context
76
+ }),
77
+ style: getBlockStyles(useBlock())
78
+ };
79
+ }
80
+
81
+ function shouldWrap() {
82
+ return !componentInfo()?.noWrap;
83
+ }
84
+
85
+ function componentOptions() {
86
+ return { ...getBlockComponentOptions(useBlock()),
127
87
 
128
- get repeatItemData() {
129
88
  /**
130
- * we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
131
- * which will not work if there is a repeat.
89
+ * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
90
+ * they are provided to the component itself directly.
132
91
  */
133
- const {
134
- repeat,
135
- ...blockWithoutRepeat
136
- } = props.block;
137
-
138
- if (!repeat?.collection) {
139
- return undefined;
140
- }
141
-
142
- const itemsArray = evaluate({
143
- code: repeat.collection,
144
- state: builderContext.state,
145
- context: builderContext.context
146
- });
147
-
148
- if (!Array.isArray(itemsArray)) {
149
- return undefined;
150
- }
151
-
152
- const collectionName = repeat.collection.split(".").pop();
153
- const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
154
- const repeatArray = itemsArray.map((item, index) => ({
155
- context: { ...builderContext,
156
- state: { ...builderContext.state,
157
- $index: index,
158
- $item: item,
159
- [itemNameToUse]: item,
160
- [`$${itemNameToUse}Index`]: index
161
- }
162
- },
163
- block: blockWithoutRepeat
164
- }));
165
- return repeatArray;
92
+ ...(shouldWrap() ? {} : {
93
+ attributes: attributes()
94
+ })
95
+ };
96
+ }
97
+
98
+ function renderComponentProps() {
99
+ return {
100
+ blockChildren: children(),
101
+ componentRef: componentRef(),
102
+ componentOptions: componentOptions(),
103
+ context: props.context
104
+ };
105
+ }
106
+
107
+ function children() {
108
+ // TO-DO: When should `canHaveChildren` dictate rendering?
109
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
110
+ // but still receive and need to render children.
111
+ // return componentInfo()?.canHaveChildren ? useBlock().children : [];
112
+ return useBlock().children ?? [];
113
+ }
114
+
115
+ function childrenWithoutParentComponent() {
116
+ /**
117
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
118
+ * we render them outside of `componentRef`.
119
+ * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
120
+ * blocks, and the children will be repeated within those blocks.
121
+ */
122
+ const shouldRenderChildrenOutsideRef = !componentRef() && !repeatItemData();
123
+ return shouldRenderChildrenOutsideRef ? children() : [];
124
+ }
125
+
126
+ function repeatItemData() {
127
+ /**
128
+ * we don't use `useBlock()` here because the processing done within its logic includes evaluating the block's bindings,
129
+ * which will not work if there is a repeat.
130
+ */
131
+ const {
132
+ repeat,
133
+ ...blockWithoutRepeat
134
+ } = props.block;
135
+
136
+ if (!repeat?.collection) {
137
+ return undefined;
138
+ }
139
+
140
+ const itemsArray = evaluate({
141
+ code: repeat.collection,
142
+ state: props.context.state,
143
+ context: props.context.context
144
+ });
145
+
146
+ if (!Array.isArray(itemsArray)) {
147
+ return undefined;
166
148
  }
167
149
 
168
- });
169
- const builderContext = useContext(BuilderContext);
170
- return <Show fallback={<RenderComponent {...state.renderComponentProps}></RenderComponent>} when={state.shouldWrap}>
171
- <Show fallback={<Dynamic {...state.attributes} component={state.tagName}></Dynamic>} when={!isEmptyHtmlElement(state.tagName)}>
172
- <Dynamic {...state.attributes} component={state.tagName}>
173
- <Show when={state.repeatItemData}>
174
- <For each={state.repeatItemData}>
150
+ const collectionName = repeat.collection.split(".").pop();
151
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
152
+ const repeatArray = itemsArray.map((item, index) => ({
153
+ context: { ...props.context,
154
+ state: { ...props.context.state,
155
+ $index: index,
156
+ $item: item,
157
+ [itemNameToUse]: item,
158
+ [`$${itemNameToUse}Index`]: index
159
+ }
160
+ },
161
+ block: blockWithoutRepeat
162
+ }));
163
+ return repeatArray;
164
+ }
165
+
166
+ return <Show fallback={<RenderComponent {...renderComponentProps()} context={props.context}></RenderComponent>} when={shouldWrap()}>
167
+ <Show fallback={<Dynamic {...attributes()} component={tagName()}></Dynamic>} when={!isEmptyHtmlElement(tagName())}>
168
+ <Dynamic {...attributes()} component={tagName()}>
169
+ <Show when={repeatItemData()}>
170
+ <For each={repeatItemData()}>
175
171
  {(data, _index) => {
176
172
  const index = _index();
177
173
 
@@ -179,21 +175,21 @@ function RenderBlock(props) {
179
175
  }}
180
176
  </For>
181
177
  </Show>
182
- <Show when={!state.repeatItemData}>
183
- <RenderComponent {...state.renderComponentProps}></RenderComponent>
178
+ <Show when={!repeatItemData()}>
179
+ <RenderComponent {...renderComponentProps()}></RenderComponent>
184
180
  </Show>
185
- <For each={state.childrenWithoutParentComponent}>
181
+ <For each={childrenWithoutParentComponent()}>
186
182
  {(child, _index) => {
187
183
  const index = _index();
188
184
 
189
- return <RenderBlock key={"render-block-" + child.id} block={child}></RenderBlock>;
185
+ return <RenderBlock key={"render-block-" + child.id} block={child} context={props.context}></RenderBlock>;
190
186
  }}
191
187
  </For>
192
- <For each={state.childrenWithoutParentComponent}>
188
+ <For each={childrenWithoutParentComponent()}>
193
189
  {(child, _index) => {
194
190
  const index = _index();
195
191
 
196
- return <BlockStyles key={"block-style-" + child.id} block={child}></BlockStyles>;
192
+ return <BlockStyles key={"block-style-" + child.id} block={child} context={props.context}></BlockStyles>;
197
193
  }}
198
194
  </For>
199
195
  </Dynamic>
@@ -10,14 +10,14 @@ function RenderComponent(props) {
10
10
  {(child, _index) => {
11
11
  const index = _index();
12
12
 
13
- return <RenderBlock key={"render-block-" + child.id} block={child}></RenderBlock>;
13
+ return <RenderBlock key={"render-block-" + child.id} block={child} context={props.context}></RenderBlock>;
14
14
  }}
15
15
  </For>
16
16
  <For each={props.blockChildren}>
17
17
  {(child, _index) => {
18
18
  const index = _index();
19
19
 
20
- return <BlockStyles key={"block-style-" + child.id} block={child}></BlockStyles>;
20
+ return <BlockStyles key={"block-style-" + child.id} block={child} context={props.context}></BlockStyles>;
21
21
  }}
22
22
  </For>
23
23
  </Dynamic>
@@ -25,7 +25,7 @@ function RenderRepeatedBlock(props) {
25
25
  }
26
26
 
27
27
  }} component={BuilderContext.Provider}>
28
- <RenderBlock block={props.block}></RenderBlock>
28
+ <RenderBlock block={props.block} context={props.repeatContext}></RenderBlock>
29
29
  </Dynamic>;
30
30
  }
31
31
 
@@ -1,54 +1,53 @@
1
- import { Show, For } from "solid-js";
2
- import { createMutable } from "solid-js/store";
1
+ import { useContext, Show, For } from "solid-js";
3
2
  import { css } from "solid-styled-components";
3
+ import BuilderContext from "../context/builder.context";
4
4
  import { isEditing } from "../functions/is-editing.js";
5
5
  import BlockStyles from "./render-block/block-styles.jsx";
6
6
  import RenderBlock from "./render-block/render-block.jsx";
7
7
 
8
8
  function RenderBlocks(props) {
9
- const state = createMutable({
10
- get className() {
11
- return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
12
- },
9
+ function className() {
10
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
11
+ }
13
12
 
14
- onClick() {
15
- if (isEditing() && !props.blocks?.length) {
16
- window.parent?.postMessage({
17
- type: "builder.clickEmptyBlocks",
18
- data: {
19
- parentElementId: props.parent,
20
- dataPath: props.path
21
- }
22
- }, "*");
23
- }
24
- },
13
+ function onClick() {
14
+ if (isEditing() && !props.blocks?.length) {
15
+ window.parent?.postMessage({
16
+ type: "builder.clickEmptyBlocks",
17
+ data: {
18
+ parentElementId: props.parent,
19
+ dataPath: props.path
20
+ }
21
+ }, "*");
22
+ }
23
+ }
25
24
 
26
- onMouseEnter() {
27
- if (isEditing() && !props.blocks?.length) {
28
- window.parent?.postMessage({
29
- type: "builder.hoverEmptyBlocks",
30
- data: {
31
- parentElementId: props.parent,
32
- dataPath: props.path
33
- }
34
- }, "*");
35
- }
25
+ function onMouseEnter() {
26
+ if (isEditing() && !props.blocks?.length) {
27
+ window.parent?.postMessage({
28
+ type: "builder.hoverEmptyBlocks",
29
+ data: {
30
+ parentElementId: props.parent,
31
+ dataPath: props.path
32
+ }
33
+ }, "*");
36
34
  }
35
+ }
37
36
 
38
- });
39
- return <div class={state.className + " " + css({
37
+ const builderContext = useContext(BuilderContext);
38
+ return <div class={className() + " " + css({
40
39
  display: "flex",
41
40
  flexDirection: "column",
42
41
  alignItems: "stretch"
43
42
  })} builder-path={props.path} builder-parent-id={props.parent} dataSet={{
44
- class: state.className
45
- }} onClick={event => state.onClick()} onMouseEnter={event => state.onMouseEnter()}>
43
+ class: className()
44
+ }} onClick={event => onClick()} onMouseEnter={event => onMouseEnter()}>
46
45
  <Show when={props.blocks}>
47
46
  <For each={props.blocks}>
48
47
  {(block, _index) => {
49
48
  const index = _index();
50
49
 
51
- return <RenderBlock key={"render-block-" + block.id} block={block}></RenderBlock>;
50
+ return <RenderBlock key={"render-block-" + block.id} block={block} context={builderContext}></RenderBlock>;
52
51
  }}
53
52
  </For>
54
53
  </Show>
@@ -57,7 +56,7 @@ function RenderBlocks(props) {
57
56
  {(block, _index) => {
58
57
  const index = _index();
59
58
 
60
- return <BlockStyles key={"block-style-" + block.id} block={block}></BlockStyles>;
59
+ return <BlockStyles key={"block-style-" + block.id} block={block} context={builderContext}></BlockStyles>;
61
60
  }}
62
61
  </For>
63
62
  </Show>
@@ -1,17 +1,15 @@
1
- import { createMutable } from "solid-js/store";
2
1
  import RenderInlinedStyles from "../../render-inlined-styles.jsx";
3
2
 
4
3
  function RenderContentStyles(props) {
5
- const state = createMutable({
6
- getCssFromFont(font) {
7
- // TODO: compute what font sizes are used and only load those.......
8
- const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
9
- const name = family.split(",")[0];
10
- const url = font.fileUrl ?? font?.files?.regular;
11
- let str = "";
4
+ function getCssFromFont(font) {
5
+ // TODO: compute what font sizes are used and only load those.......
6
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
7
+ const name = family.split(",")[0];
8
+ const url = font.fileUrl ?? font?.files?.regular;
9
+ let str = "";
12
10
 
13
- if (url && family && name) {
14
- str += `
11
+ if (url && family && name) {
12
+ str += `
15
13
  @font-face {
16
14
  font-family: "${family}";
17
15
  src: local("${name}"), url('${url}') format('woff2');
@@ -19,21 +17,21 @@ function RenderContentStyles(props) {
19
17
  font-weight: 400;
20
18
  }
21
19
  `.trim();
22
- }
20
+ }
23
21
 
24
- if (font.files) {
25
- for (const weight in font.files) {
26
- const isNumber = String(Number(weight)) === weight;
22
+ if (font.files) {
23
+ for (const weight in font.files) {
24
+ const isNumber = String(Number(weight)) === weight;
27
25
 
28
- if (!isNumber) {
29
- continue;
30
- } // TODO: maybe limit number loaded
26
+ if (!isNumber) {
27
+ continue;
28
+ } // TODO: maybe limit number loaded
31
29
 
32
30
 
33
- const weightUrl = font.files[weight];
31
+ const weightUrl = font.files[weight];
34
32
 
35
- if (weightUrl && weightUrl !== url) {
36
- str += `
33
+ if (weightUrl && weightUrl !== url) {
34
+ str += `
37
35
  @font-face {
38
36
  font-family: "${family}";
39
37
  src: url('${weightUrl}') format('woff2');
@@ -41,34 +39,33 @@ function RenderContentStyles(props) {
41
39
  font-weight: ${weight};
42
40
  }
43
41
  `.trim();
44
- }
45
42
  }
46
43
  }
44
+ }
47
45
 
48
- return str;
49
- },
46
+ return str;
47
+ }
50
48
 
51
- getFontCss({
52
- customFonts
53
- }) {
54
- // TODO: flag for this
55
- // if (!this.builder.allowCustomFonts) {
56
- // return '';
57
- // }
58
- // TODO: separate internal data from external
59
- return customFonts?.map(font => this.getCssFromFont(font))?.join(" ") || "";
60
- },
49
+ function getFontCss({
50
+ customFonts
51
+ }) {
52
+ // TODO: flag for this
53
+ // if (!this.builder.allowCustomFonts) {
54
+ // return '';
55
+ // }
56
+ // TODO: separate internal data from external
57
+ return customFonts?.map(font => this.getCssFromFont(font))?.join(" ") || "";
58
+ }
61
59
 
62
- get injectedStyles() {
63
- return `
60
+ function injectedStyles() {
61
+ return `
64
62
  ${props.cssCode || ""}
65
- ${state.getFontCss({
66
- customFonts: props.customFonts
67
- })}`;
68
- }
63
+ ${getFontCss({
64
+ customFonts: props.customFonts
65
+ })}`;
66
+ }
69
67
 
70
- });
71
- return <RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>;
68
+ return <RenderInlinedStyles styles={injectedStyles()}></RenderInlinedStyles>;
72
69
  }
73
70
 
74
71
  export default RenderContentStyles;