@builder.io/sdk-vue 0.0.1-50 → 0.0.1-53

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 (182) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/nuxt.js +1 -0
  3. package/nuxt2/src/blocks/button/button.vue +19 -0
  4. package/nuxt2/src/blocks/button/component-info.js +48 -0
  5. package/nuxt2/src/blocks/columns/columns.vue +107 -0
  6. package/nuxt2/src/blocks/columns/component-info.js +224 -0
  7. package/nuxt2/src/blocks/custom-code/component-info.js +38 -0
  8. package/nuxt2/src/blocks/custom-code/custom-code.vue +79 -0
  9. package/nuxt2/src/blocks/embed/component-info.js +31 -0
  10. package/nuxt2/src/blocks/embed/embed.vue +60 -0
  11. package/nuxt2/src/blocks/form/component-info.js +269 -0
  12. package/nuxt2/src/blocks/form/form.vue +310 -0
  13. package/nuxt2/src/blocks/fragment/component-info.js +18 -0
  14. package/nuxt2/src/blocks/fragment/fragment.vue +10 -0
  15. package/nuxt2/src/blocks/image/component-info.js +111 -0
  16. package/nuxt2/src/blocks/image/image.vue +101 -0
  17. package/nuxt2/src/blocks/img/component-info.js +27 -0
  18. package/nuxt2/src/blocks/img/img.vue +29 -0
  19. package/nuxt2/src/blocks/input/component-info.js +81 -0
  20. package/nuxt2/src/blocks/input/input.vue +31 -0
  21. package/nuxt2/src/blocks/raw-text/component-info.js +23 -0
  22. package/nuxt2/src/blocks/raw-text/raw-text.vue +27 -0
  23. package/nuxt2/src/blocks/section/component-info.js +56 -0
  24. package/nuxt2/src/blocks/section/section.vue +21 -0
  25. package/nuxt2/src/blocks/select/component-info.js +66 -0
  26. package/nuxt2/src/blocks/select/select.vue +28 -0
  27. package/nuxt2/src/blocks/submit-button/component-info.js +35 -0
  28. package/nuxt2/src/blocks/submit-button/submit-button.vue +12 -0
  29. package/nuxt2/src/blocks/symbol/component-info.js +49 -0
  30. package/nuxt2/src/blocks/symbol/symbol.vue +89 -0
  31. package/nuxt2/src/blocks/text/component-info.js +31 -0
  32. package/nuxt2/src/blocks/text/text.vue +10 -0
  33. package/nuxt2/src/blocks/textarea/component-info.js +54 -0
  34. package/nuxt2/src/blocks/textarea/textarea.vue +16 -0
  35. package/nuxt2/src/blocks/video/component-info.js +113 -0
  36. package/nuxt2/src/blocks/video/video.vue +39 -0
  37. package/nuxt2/src/components/render-block/block-styles.vue +44 -0
  38. package/nuxt2/src/components/render-block/render-block.helpers.js +30 -0
  39. package/nuxt2/src/components/{render-block.vue → render-block/render-block.vue} +31 -17
  40. package/nuxt2/src/components/render-blocks.vue +4 -4
  41. package/nuxt2/src/components/render-content/components/render-styles.vue +80 -0
  42. package/nuxt2/src/components/render-content/index.js +27 -0
  43. package/nuxt2/src/components/{render-content.vue → render-content/render-content.vue} +82 -98
  44. package/nuxt2/src/components/render-inlined-styles.vue +26 -0
  45. package/nuxt2/src/constants/builder-registered-components.js +66 -0
  46. package/{vue3/src/functions/get-target.js → nuxt2/src/constants/target.js} +2 -4
  47. package/nuxt2/src/functions/evaluate.js +2 -2
  48. package/{vue2/src/functions/is-react-native.js → nuxt2/src/functions/fast-clone.js} +2 -4
  49. package/nuxt2/src/functions/get-block-actions.js +2 -2
  50. package/nuxt2/src/functions/get-content/index.js +3 -2
  51. package/nuxt2/src/functions/get-fetch.js +29 -7
  52. package/nuxt2/src/functions/get-processed-block.js +3 -3
  53. package/nuxt2/src/functions/get-processed-block.test.js +1 -1
  54. package/nuxt2/src/functions/if-target.js +27 -2
  55. package/nuxt2/src/functions/is-editing.js +1 -1
  56. package/nuxt2/src/functions/is-iframe.js +1 -1
  57. package/nuxt2/src/functions/is-previewing.js +2 -2
  58. package/nuxt2/src/functions/on-change.test.js +1 -1
  59. package/nuxt2/src/functions/previewing-model-name.js +1 -1
  60. package/nuxt2/src/functions/register-component.js +30 -13
  61. package/nuxt2/src/functions/register.js +1 -1
  62. package/nuxt2/src/functions/set-editor-settings.js +1 -1
  63. package/nuxt2/src/functions/set.test.js +1 -1
  64. package/nuxt2/src/functions/track.js +4 -4
  65. package/nuxt2/src/index.js +10 -13
  66. package/nuxt2/src/scripts/init-editing.js +72 -62
  67. package/nuxt2/src/types/components.js +3 -0
  68. package/nuxt2/src/types/element.js +3 -0
  69. package/nuxt2/src/types/targets.js +3 -0
  70. package/package.json +2 -1
  71. package/vue2/src/blocks/button/component-info.js +48 -0
  72. package/vue2/src/blocks/columns/component-info.js +224 -0
  73. package/vue2/src/blocks/custom-code/component-info.js +38 -0
  74. package/vue2/src/blocks/embed/component-info.js +31 -0
  75. package/vue2/src/blocks/form/component-info.js +269 -0
  76. package/vue2/src/blocks/fragment/component-info.js +18 -0
  77. package/vue2/src/blocks/image/component-info.js +111 -0
  78. package/vue2/src/blocks/img/component-info.js +27 -0
  79. package/vue2/src/blocks/input/component-info.js +81 -0
  80. package/vue2/src/blocks/raw-text/component-info.js +23 -0
  81. package/vue2/src/blocks/section/component-info.js +56 -0
  82. package/vue2/src/blocks/select/component-info.js +66 -0
  83. package/vue2/src/blocks/submit-button/component-info.js +35 -0
  84. package/vue2/src/blocks/symbol/component-info.js +49 -0
  85. package/vue2/src/blocks/text/component-info.js +31 -0
  86. package/vue2/src/blocks/textarea/component-info.js +54 -0
  87. package/vue2/src/blocks/video/component-info.js +113 -0
  88. package/vue2/src/components/render-block/render-block.helpers.js +30 -0
  89. package/vue2/src/components/render-content/index.js +27 -0
  90. package/vue2/src/constants/builder-registered-components.js +66 -0
  91. package/{nuxt2/src/functions/get-target.js → vue2/src/constants/target.js} +2 -4
  92. package/vue2/src/functions/evaluate.js +2 -2
  93. package/{nuxt2/src/functions/is-react-native.js → vue2/src/functions/fast-clone.js} +2 -4
  94. package/vue2/src/functions/get-block-actions.js +2 -2
  95. package/vue2/src/functions/get-content/index.js +3 -2
  96. package/vue2/src/functions/get-fetch.js +29 -7
  97. package/vue2/src/functions/get-processed-block.js +3 -3
  98. package/vue2/src/functions/get-processed-block.test.js +1 -1
  99. package/vue2/src/functions/if-target.js +27 -2
  100. package/vue2/src/functions/is-editing.js +1 -1
  101. package/vue2/src/functions/is-iframe.js +1 -1
  102. package/vue2/src/functions/is-previewing.js +2 -2
  103. package/vue2/src/functions/on-change.test.js +1 -1
  104. package/vue2/src/functions/previewing-model-name.js +1 -1
  105. package/vue2/src/functions/register-component.js +30 -13
  106. package/vue2/src/functions/register.js +1 -1
  107. package/vue2/src/functions/set-editor-settings.js +1 -1
  108. package/vue2/src/functions/set.test.js +1 -1
  109. package/vue2/src/functions/track.js +4 -4
  110. package/vue2/src/index.js +10 -13
  111. package/vue2/src/scripts/init-editing.js +72 -62
  112. package/vue2/src/types/components.js +3 -0
  113. package/vue2/src/types/element.js +3 -0
  114. package/vue2/src/types/targets.js +3 -0
  115. package/vue3/src/blocks/button/component-info.js +48 -0
  116. package/vue3/src/blocks/columns/component-info.js +224 -0
  117. package/vue3/src/blocks/custom-code/component-info.js +38 -0
  118. package/vue3/src/blocks/embed/component-info.js +31 -0
  119. package/vue3/src/blocks/form/component-info.js +269 -0
  120. package/vue3/src/blocks/fragment/component-info.js +18 -0
  121. package/vue3/src/blocks/image/component-info.js +111 -0
  122. package/vue3/src/blocks/img/component-info.js +27 -0
  123. package/vue3/src/blocks/input/component-info.js +81 -0
  124. package/vue3/src/blocks/raw-text/component-info.js +23 -0
  125. package/vue3/src/blocks/section/component-info.js +56 -0
  126. package/vue3/src/blocks/select/component-info.js +66 -0
  127. package/vue3/src/blocks/submit-button/component-info.js +35 -0
  128. package/vue3/src/blocks/symbol/component-info.js +49 -0
  129. package/vue3/src/blocks/text/component-info.js +31 -0
  130. package/vue3/src/blocks/textarea/component-info.js +54 -0
  131. package/vue3/src/blocks/video/component-info.js +113 -0
  132. package/vue3/src/components/render-block/render-block.helpers.js +30 -0
  133. package/vue3/src/components/render-content/index.js +27 -0
  134. package/vue3/src/constants/builder-registered-components.js +66 -0
  135. package/{vue2/src/functions/get-target.js → vue3/src/constants/target.js} +2 -4
  136. package/vue3/src/functions/evaluate.js +2 -2
  137. package/vue3/src/functions/fast-clone.js +11 -0
  138. package/vue3/src/functions/get-block-actions.js +2 -2
  139. package/vue3/src/functions/get-content/index.js +3 -2
  140. package/vue3/src/functions/get-fetch.js +29 -7
  141. package/vue3/src/functions/get-processed-block.js +3 -3
  142. package/vue3/src/functions/get-processed-block.test.js +1 -1
  143. package/vue3/src/functions/if-target.js +27 -2
  144. package/vue3/src/functions/is-editing.js +1 -1
  145. package/vue3/src/functions/is-iframe.js +1 -1
  146. package/vue3/src/functions/is-previewing.js +2 -2
  147. package/vue3/src/functions/on-change.test.js +1 -1
  148. package/vue3/src/functions/previewing-model-name.js +1 -1
  149. package/vue3/src/functions/register-component.js +30 -13
  150. package/vue3/src/functions/register.js +1 -1
  151. package/vue3/src/functions/set-editor-settings.js +1 -1
  152. package/vue3/src/functions/set.test.js +1 -1
  153. package/vue3/src/functions/track.js +4 -4
  154. package/vue3/src/index.js +10 -13
  155. package/vue3/src/scripts/init-editing.js +72 -62
  156. package/vue3/src/types/components.js +3 -0
  157. package/vue3/src/types/element.js +3 -0
  158. package/vue3/src/types/targets.js +3 -0
  159. package/nuxt2/src/blocks/button.vue +0 -53
  160. package/nuxt2/src/blocks/columns.vue +0 -325
  161. package/nuxt2/src/blocks/custom-code.vue +0 -112
  162. package/nuxt2/src/blocks/embed.vue +0 -87
  163. package/nuxt2/src/blocks/form.vue +0 -523
  164. package/nuxt2/src/blocks/fragment.vue +0 -22
  165. package/nuxt2/src/blocks/image.vue +0 -189
  166. package/nuxt2/src/blocks/img.vue +0 -51
  167. package/nuxt2/src/blocks/input.vue +0 -101
  168. package/nuxt2/src/blocks/raw-text.vue +0 -37
  169. package/nuxt2/src/blocks/section.vue +0 -64
  170. package/nuxt2/src/blocks/select.vue +0 -63
  171. package/nuxt2/src/blocks/submit-button.vue +0 -36
  172. package/nuxt2/src/blocks/symbol.vue +0 -121
  173. package/nuxt2/src/blocks/text.vue +0 -36
  174. package/nuxt2/src/blocks/textarea.vue +0 -51
  175. package/nuxt2/src/blocks/video.vue +0 -119
  176. package/nuxt2/src/components/block-styles.vue +0 -34
  177. package/nuxt2/src/functions/apply-patch-with-mutation.js +0 -87
  178. package/vue2/src/components/block-styles.vue +0 -34
  179. package/vue2/src/functions/apply-patch-with-mutation.js +0 -87
  180. package/vue3/src/components/block-styles.vue +0 -34
  181. package/vue3/src/functions/apply-patch-with-mutation.js +0 -87
  182. package/vue3/src/functions/is-react-native.js +0 -13
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 0.0.1-51
2
+
3
+ ⚠️ Deprecation notice: Registering components via `registerComponent(component, info)` is now deprecated.
4
+ To register your custom components in Builder, you must now provide a `customComponents` array to the `RenderContent` component containing `[{ component, info }]`.
5
+ See [builder-registered-components.ts](/packages/sdks/src/constants/builder-registered-components.ts) for examples of how to do so, or see the example provided for this SDK.
6
+
7
+ ### 0.0.1-50
8
+
9
+ - feat: 🎸 export `isPreviewing()` (https://github.com/BuilderIO/builder/pull/951)
10
+ - feat: 🎸 Add support for Symbols (https://github.com/BuilderIO/builder/pull/951)
11
+ - feat: 🎸 Add support for Data Bindings https://github.com/BuilderIO/builder/pull/970
12
+
13
+ - BREAKING CHANGE: 🧨 RenderContent must now be provided the `apiKey` as a prop (https://github.com/BuilderIO/builder/pull/951)
1
14
  ### 0.0.1-49
2
15
 
3
16
  - Fix: show the "+ add block" button on empty pages https://github.com/BuilderIO/builder/pull/934
package/nuxt.js CHANGED
@@ -18,6 +18,7 @@ export default function () {
18
18
  dirs.push({
19
19
  path: join(__dirname, 'nuxt2/src/blocks'),
20
20
  prefix: 'builder',
21
+ pattern: "**/index.*",
21
22
  });
22
23
  });
23
24
  }
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <a
3
+ v-bind="attributes"
4
+ role="button"
5
+ v-if="link"
6
+ :href="link"
7
+ :target="openLinkInNewTab ? '_blank' : undefined"
8
+ >
9
+ {{ text }}
10
+ </a>
11
+ <span v-bind="attributes" v-else="">{{ text }}</span>
12
+ </template>
13
+ <script>
14
+ export default {
15
+ name: "builder-button",
16
+
17
+ props: ["attributes", "text", "link", "openLinkInNewTab"],
18
+ };
19
+ </script>
@@ -0,0 +1,48 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
3
+ var __export = (target, all) => {
4
+ __markAsModule(target);
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+ __export(exports, {
9
+ componentInfo: () => componentInfo
10
+ });
11
+ const componentInfo = {
12
+ name: "Core:Button",
13
+ builtIn: true,
14
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
15
+ defaultStyles: {
16
+ appearance: "none",
17
+ paddingTop: "15px",
18
+ paddingBottom: "15px",
19
+ paddingLeft: "25px",
20
+ paddingRight: "25px",
21
+ backgroundColor: "#000000",
22
+ color: "white",
23
+ borderRadius: "4px",
24
+ textAlign: "center",
25
+ cursor: "pointer"
26
+ },
27
+ inputs: [
28
+ {
29
+ name: "text",
30
+ type: "text",
31
+ defaultValue: "Click me!",
32
+ bubble: true
33
+ },
34
+ {
35
+ name: "link",
36
+ type: "url",
37
+ bubble: true
38
+ },
39
+ {
40
+ name: "openLinkInNewTab",
41
+ type: "boolean",
42
+ defaultValue: false,
43
+ friendlyName: "Open link in new tab"
44
+ }
45
+ ],
46
+ static: true,
47
+ noWrap: true
48
+ };
@@ -0,0 +1,107 @@
1
+ <template>
2
+ <div class="builder-columns div-4wbls88y960" :style="columnsCssVars">
3
+ <div
4
+ class="builder-column div-4wbls88y960-2"
5
+ v-for="(column, index) in columns"
6
+ :style="{
7
+ width: getColumnCssWidth(index),
8
+ marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
9
+ ...columnCssVars,
10
+ }"
11
+ :key="index"
12
+ >
13
+ <render-blocks :blocks="column.blocks"></render-blocks>
14
+ </div>
15
+ </div>
16
+ </template>
17
+ <script>
18
+ import RenderBlocks from "../../components/render-blocks";
19
+
20
+ export default {
21
+ name: "builder-columns",
22
+ components: { "render-blocks": async () => RenderBlocks },
23
+ props: ["space", "columns", "stackColumnsAt", "reverseColumnsWhenStacked"],
24
+
25
+ computed: {
26
+ columnsCssVars() {
27
+ const flexDir =
28
+ this.stackColumnsAt === "never"
29
+ ? "inherit"
30
+ : this.reverseColumnsWhenStacked
31
+ ? "column-reverse"
32
+ : "column";
33
+ return {
34
+ "--flex-dir": flexDir,
35
+ "--flex-dir-tablet": this.maybeApplyForTablet(flexDir),
36
+ };
37
+ },
38
+ columnCssVars() {
39
+ const width = "100%";
40
+ const marginLeft = "0";
41
+ return {
42
+ "--column-width": width,
43
+ "--column-margin-left": marginLeft,
44
+ "--column-width-tablet": this.maybeApplyForTablet(width),
45
+ "--column-margin-left-tablet": this.maybeApplyForTablet(marginLeft),
46
+ };
47
+ },
48
+ },
49
+
50
+ methods: {
51
+ getGutterSize() {
52
+ return typeof this.space === "number" ? this.space || 0 : 20;
53
+ },
54
+ getColumns() {
55
+ return this.columns || [];
56
+ },
57
+ getWidth(index) {
58
+ const columns = this.getColumns();
59
+ return columns[index]?.width || 100 / columns.length;
60
+ },
61
+ getColumnCssWidth(index) {
62
+ const columns = this.getColumns();
63
+ const gutterSize = this.getGutterSize();
64
+ const subtractWidth =
65
+ (gutterSize * (columns.length - 1)) / columns.length;
66
+ return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
67
+ },
68
+ maybeApplyForTablet(prop) {
69
+ const _stackColumnsAt = this.stackColumnsAt || "tablet";
70
+
71
+ return _stackColumnsAt === "tablet" ? prop : "inherit";
72
+ },
73
+ },
74
+ };
75
+ </script>
76
+ <style scoped>
77
+ .div-4wbls88y960 {
78
+ display: flex;
79
+ align-items: stretch;
80
+ line-height: normal;
81
+ }
82
+ @media (max-width: 999px) {
83
+ .div-4wbls88y960 {
84
+ flex-direction: var(--flex-dir-tablet);
85
+ }
86
+ }
87
+ @media (max-width: 639px) {
88
+ .div-4wbls88y960 {
89
+ flex-direction: var(--flex-dir);
90
+ }
91
+ }
92
+ .div-4wbls88y960-2 {
93
+ flex-grow: 1;
94
+ }
95
+ @media (max-width: 999px) {
96
+ .div-4wbls88y960-2 {
97
+ width: var(--column-width-tablet) !important;
98
+ margin-left: var(--column-margin-left-tablet) !important;
99
+ }
100
+ }
101
+ @media (max-width: 639px) {
102
+ .div-4wbls88y960-2 {
103
+ width: var(--column-width) !important;
104
+ margin-left: var(--column-margin-left) !important;
105
+ }
106
+ }
107
+ </style>
@@ -0,0 +1,224 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
3
+ var __export = (target, all) => {
4
+ __markAsModule(target);
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+ __export(exports, {
9
+ componentInfo: () => componentInfo
10
+ });
11
+ const componentInfo = {
12
+ name: "Columns",
13
+ builtIn: true,
14
+ inputs: [
15
+ {
16
+ name: "columns",
17
+ type: "array",
18
+ broadcast: true,
19
+ subFields: [
20
+ {
21
+ name: "blocks",
22
+ type: "array",
23
+ hideFromUI: true,
24
+ defaultValue: [
25
+ {
26
+ "@type": "@builder.io/sdk:Element",
27
+ responsiveStyles: {
28
+ large: {
29
+ display: "flex",
30
+ flexDirection: "column",
31
+ alignItems: "stretch",
32
+ flexShrink: "0",
33
+ position: "relative",
34
+ marginTop: "30px",
35
+ textAlign: "center",
36
+ lineHeight: "normal",
37
+ height: "auto",
38
+ minHeight: "20px",
39
+ minWidth: "20px",
40
+ overflow: "hidden"
41
+ }
42
+ },
43
+ component: {
44
+ name: "Image",
45
+ options: {
46
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
47
+ backgroundPosition: "center",
48
+ backgroundSize: "cover",
49
+ aspectRatio: 0.7004048582995948
50
+ }
51
+ }
52
+ },
53
+ {
54
+ "@type": "@builder.io/sdk:Element",
55
+ responsiveStyles: {
56
+ large: {
57
+ display: "flex",
58
+ flexDirection: "column",
59
+ alignItems: "stretch",
60
+ flexShrink: "0",
61
+ position: "relative",
62
+ marginTop: "30px",
63
+ textAlign: "center",
64
+ lineHeight: "normal",
65
+ height: "auto"
66
+ }
67
+ },
68
+ component: {
69
+ name: "Text",
70
+ options: {
71
+ text: "<p>Enter some text...</p>"
72
+ }
73
+ }
74
+ }
75
+ ]
76
+ },
77
+ {
78
+ name: "width",
79
+ type: "number",
80
+ hideFromUI: true,
81
+ helperText: "Width %, e.g. set to 50 to fill half of the space"
82
+ },
83
+ {
84
+ name: "link",
85
+ type: "url",
86
+ helperText: "Optionally set a url that clicking this column will link to"
87
+ }
88
+ ],
89
+ defaultValue: [
90
+ {
91
+ blocks: [
92
+ {
93
+ "@type": "@builder.io/sdk:Element",
94
+ responsiveStyles: {
95
+ large: {
96
+ display: "flex",
97
+ flexDirection: "column",
98
+ alignItems: "stretch",
99
+ flexShrink: "0",
100
+ position: "relative",
101
+ marginTop: "30px",
102
+ textAlign: "center",
103
+ lineHeight: "normal",
104
+ height: "auto",
105
+ minHeight: "20px",
106
+ minWidth: "20px",
107
+ overflow: "hidden"
108
+ }
109
+ },
110
+ component: {
111
+ name: "Image",
112
+ options: {
113
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
114
+ backgroundPosition: "center",
115
+ backgroundSize: "cover",
116
+ aspectRatio: 0.7004048582995948
117
+ }
118
+ }
119
+ },
120
+ {
121
+ "@type": "@builder.io/sdk:Element",
122
+ responsiveStyles: {
123
+ large: {
124
+ display: "flex",
125
+ flexDirection: "column",
126
+ alignItems: "stretch",
127
+ flexShrink: "0",
128
+ position: "relative",
129
+ marginTop: "30px",
130
+ textAlign: "center",
131
+ lineHeight: "normal",
132
+ height: "auto"
133
+ }
134
+ },
135
+ component: {
136
+ name: "Text",
137
+ options: {
138
+ text: "<p>Enter some text...</p>"
139
+ }
140
+ }
141
+ }
142
+ ]
143
+ },
144
+ {
145
+ blocks: [
146
+ {
147
+ "@type": "@builder.io/sdk:Element",
148
+ responsiveStyles: {
149
+ large: {
150
+ display: "flex",
151
+ flexDirection: "column",
152
+ alignItems: "stretch",
153
+ flexShrink: "0",
154
+ position: "relative",
155
+ marginTop: "30px",
156
+ textAlign: "center",
157
+ lineHeight: "normal",
158
+ height: "auto",
159
+ minHeight: "20px",
160
+ minWidth: "20px",
161
+ overflow: "hidden"
162
+ }
163
+ },
164
+ component: {
165
+ name: "Image",
166
+ options: {
167
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
168
+ backgroundPosition: "center",
169
+ backgroundSize: "cover",
170
+ aspectRatio: 0.7004048582995948
171
+ }
172
+ }
173
+ },
174
+ {
175
+ "@type": "@builder.io/sdk:Element",
176
+ responsiveStyles: {
177
+ large: {
178
+ display: "flex",
179
+ flexDirection: "column",
180
+ alignItems: "stretch",
181
+ flexShrink: "0",
182
+ position: "relative",
183
+ marginTop: "30px",
184
+ textAlign: "center",
185
+ lineHeight: "normal",
186
+ height: "auto"
187
+ }
188
+ },
189
+ component: {
190
+ name: "Text",
191
+ options: {
192
+ text: "<p>Enter some text...</p>"
193
+ }
194
+ }
195
+ }
196
+ ]
197
+ }
198
+ ],
199
+ onChange: " function clearWidths() { columns.forEach(col => { col.delete('width'); }); } const columns = options.get('columns') as Array<Map<String, any>>; if (Array.isArray(columns)) { const containsColumnWithWidth = !!columns.find(col => col.get('width')); if (containsColumnWithWidth) { const containsColumnWithoutWidth = !!columns.find(col => !col.get('width')); if (containsColumnWithoutWidth) { clearWidths(); } else { const sumWidths = columns.reduce((memo, col) => { return memo + col.get('width'); }, 0); const widthsDontAddUp = sumWidths !== 100; if (widthsDontAddUp) { clearWidths(); } } } } "
200
+ },
201
+ {
202
+ name: "space",
203
+ type: "number",
204
+ defaultValue: 20,
205
+ helperText: "Size of gap between columns",
206
+ advanced: true
207
+ },
208
+ {
209
+ name: "stackColumnsAt",
210
+ type: "string",
211
+ defaultValue: "tablet",
212
+ helperText: "Convert horizontal columns to vertical at what device size",
213
+ enum: ["tablet", "mobile", "never"],
214
+ advanced: true
215
+ },
216
+ {
217
+ name: "reverseColumnsWhenStacked",
218
+ type: "boolean",
219
+ defaultValue: false,
220
+ helperText: "When stacking columns for mobile devices, reverse the ordering",
221
+ advanced: true
222
+ }
223
+ ]
224
+ };
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
3
+ var __export = (target, all) => {
4
+ __markAsModule(target);
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+ __export(exports, {
9
+ componentInfo: () => componentInfo
10
+ });
11
+ const componentInfo = {
12
+ name: "Custom Code",
13
+ static: true,
14
+ builtIn: true,
15
+ requiredPermissions: ["editCode"],
16
+ inputs: [
17
+ {
18
+ name: "code",
19
+ type: "html",
20
+ required: true,
21
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
22
+ code: true
23
+ },
24
+ {
25
+ name: "replaceNodes",
26
+ type: "boolean",
27
+ helperText: "Preserve server rendered dom nodes",
28
+ advanced: true
29
+ },
30
+ {
31
+ name: "scriptsClientOnly",
32
+ type: "boolean",
33
+ defaultValue: false,
34
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
35
+ advanced: true
36
+ }
37
+ ]
38
+ };
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <div
3
+ ref="elem"
4
+ :class="
5
+ _classStringToObject(
6
+ 'builder-custom-code' + (this.replaceNodes ? ' replace-nodes' : '')
7
+ )
8
+ "
9
+ v-html="code"
10
+ ></div>
11
+ </template>
12
+ <script>
13
+ export default {
14
+ name: "builder-custom-code",
15
+
16
+ props: ["replaceNodes", "code"],
17
+
18
+ data: () => ({ scriptsInserted: [], scriptsRun: [] }),
19
+
20
+ mounted() {
21
+ this.findAndRunScripts();
22
+ },
23
+
24
+ methods: {
25
+ findAndRunScripts() {
26
+ // TODO: Move this function to standalone one in '@builder.io/utils'
27
+ if (this.$refs.elem && typeof window !== "undefined") {
28
+ /** @type {HTMLScriptElement[]} */
29
+ const scripts = this.$refs.elem.getElementsByTagName("script");
30
+
31
+ for (let i = 0; i < scripts.length; i++) {
32
+ const script = scripts[i];
33
+
34
+ if (script.src) {
35
+ if (this.scriptsInserted.includes(script.src)) {
36
+ continue;
37
+ }
38
+
39
+ this.scriptsInserted.push(script.src);
40
+ const newScript = document.createElement("script");
41
+ newScript.async = true;
42
+ newScript.src = script.src;
43
+ document.head.appendChild(newScript);
44
+ } else if (
45
+ !script.type ||
46
+ [
47
+ "text/javascript",
48
+ "application/javascript",
49
+ "application/ecmascript",
50
+ ].includes(script.type)
51
+ ) {
52
+ if (this.scriptsRun.includes(script.innerText)) {
53
+ continue;
54
+ }
55
+
56
+ try {
57
+ this.scriptsRun.push(script.innerText);
58
+ new Function(script.innerText)();
59
+ } catch (error) {
60
+ console.warn("`CustomCode`: Error running script:", error);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ },
66
+ _classStringToObject(str) {
67
+ const obj = {};
68
+ if (typeof str !== "string") {
69
+ return obj;
70
+ }
71
+ const classNames = str.trim().split(/\s+/);
72
+ for (const name of classNames) {
73
+ obj[name] = true;
74
+ }
75
+ return obj;
76
+ },
77
+ },
78
+ };
79
+ </script>
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
3
+ var __export = (target, all) => {
4
+ __markAsModule(target);
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+ __export(exports, {
9
+ componentInfo: () => componentInfo
10
+ });
11
+ const componentInfo = {
12
+ name: "Embed",
13
+ static: true,
14
+ builtIn: true,
15
+ inputs: [
16
+ {
17
+ name: "url",
18
+ type: "url",
19
+ required: true,
20
+ defaultValue: "",
21
+ helperText: "e.g. enter a youtube url, google map, etc",
22
+ onChange: " const url = options.get('url'); if (url) { options.set('content', 'Loading...'); // TODO: get this out of here! const apiKey = 'ae0e60e78201a3f2b0de4b'; return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`) .then(res => res.json()) .then(data => { if (options.get('url') === url) { if (data.html) { options.set('content', data.html); } else { options.set('content', 'Invalid url, please try another'); } } }) .catch(err => { options.set( 'content', 'There was an error embedding this URL, please try again or another URL' ); }); } else { options.delete('content'); } "
23
+ },
24
+ {
25
+ name: "content",
26
+ type: "html",
27
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
28
+ hideFromUI: true
29
+ }
30
+ ]
31
+ };
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <div class="builder-embed" ref="elem" v-html="content"></div>
3
+ </template>
4
+ <script>
5
+ export default {
6
+ name: "builder-embed",
7
+
8
+ props: ["content"],
9
+
10
+ data: () => ({ scriptsInserted: [], scriptsRun: [] }),
11
+
12
+ mounted() {
13
+ this.findAndRunScripts();
14
+ },
15
+
16
+ methods: {
17
+ findAndRunScripts() {
18
+ // TODO: Move this function to standalone one in '@builder.io/utils'
19
+ if (this.$refs.elem && typeof window !== "undefined") {
20
+ /** @type {HTMLScriptElement[]} */
21
+ const scripts = this.$refs.elem.getElementsByTagName("script");
22
+
23
+ for (let i = 0; i < scripts.length; i++) {
24
+ const script = scripts[i];
25
+
26
+ if (script.src) {
27
+ if (this.scriptsInserted.includes(script.src)) {
28
+ continue;
29
+ }
30
+
31
+ this.scriptsInserted.push(script.src);
32
+ const newScript = document.createElement("script");
33
+ newScript.async = true;
34
+ newScript.src = script.src;
35
+ document.head.appendChild(newScript);
36
+ } else if (
37
+ !script.type ||
38
+ [
39
+ "text/javascript",
40
+ "application/javascript",
41
+ "application/ecmascript",
42
+ ].includes(script.type)
43
+ ) {
44
+ if (this.scriptsRun.includes(script.innerText)) {
45
+ continue;
46
+ }
47
+
48
+ try {
49
+ this.scriptsRun.push(script.innerText);
50
+ new Function(script.innerText)();
51
+ } catch (error) {
52
+ console.warn("`Embed`: Error running script:", error);
53
+ }
54
+ }
55
+ }
56
+ }
57
+ },
58
+ },
59
+ };
60
+ </script>