@builder.io/sdk-react-native 1.0.33 → 1.0.35
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/lib/browser/commonjs/blocks/embed/component-info.js +3 -2
- package/lib/browser/commonjs/blocks/embed/component-info.js.map +1 -1
- package/lib/browser/commonjs/blocks/image/component-info.js +1 -1
- package/lib/browser/commonjs/blocks/image/component-info.js.map +1 -1
- package/lib/browser/commonjs/blocks/text/text.js +1 -1
- package/lib/browser/commonjs/constants/sdk-version.js +1 -1
- package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
- package/lib/browser/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/browser/commonjs/functions/extract-css-var-default-value.js +19 -0
- package/lib/browser/commonjs/functions/extract-css-var-default-value.js.map +1 -0
- package/lib/browser/commonjs/functions/transform-style-property.js +3 -1
- package/lib/browser/commonjs/functions/transform-style-property.js.map +1 -1
- package/lib/browser/commonjs/helpers/cookie.js +12 -2
- package/lib/browser/commonjs/helpers/cookie.js.map +1 -1
- package/lib/browser/module/blocks/embed/component-info.js +3 -2
- package/lib/browser/module/blocks/embed/component-info.js.map +1 -1
- package/lib/browser/module/blocks/image/component-info.js +1 -1
- package/lib/browser/module/blocks/image/component-info.js.map +1 -1
- package/lib/browser/module/blocks/text/text.js +1 -1
- package/lib/browser/module/blocks/text/text.js.map +1 -1
- package/lib/browser/module/constants/sdk-version.js +1 -1
- package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
- package/lib/browser/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/browser/module/functions/extract-css-var-default-value.js +13 -0
- package/lib/browser/module/functions/extract-css-var-default-value.js.map +1 -0
- package/lib/browser/module/functions/transform-style-property.js +3 -1
- package/lib/browser/module/functions/transform-style-property.js.map +1 -1
- package/lib/browser/module/helpers/cookie.js +11 -2
- package/lib/browser/module/helpers/cookie.js.map +1 -1
- package/lib/browser/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/browser/typescript/functions/extract-css-var-default-value.d.ts +2 -0
- package/lib/browser/typescript/functions/extract-css-var-default-value.d.ts.map +1 -0
- package/lib/browser/typescript/functions/transform-style-property.d.ts.map +1 -1
- package/lib/browser/typescript/helpers/cookie.d.ts +1 -0
- package/lib/browser/typescript/helpers/cookie.d.ts.map +1 -1
- package/lib/edge/commonjs/blocks/embed/component-info.js +3 -2
- package/lib/edge/commonjs/blocks/embed/component-info.js.map +1 -1
- package/lib/edge/commonjs/blocks/image/component-info.js +1 -1
- package/lib/edge/commonjs/blocks/image/component-info.js.map +1 -1
- package/lib/edge/commonjs/blocks/text/text.js +1 -1
- package/lib/edge/commonjs/constants/sdk-version.js +1 -1
- package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
- package/lib/edge/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/edge/commonjs/functions/extract-css-var-default-value.js +19 -0
- package/lib/edge/commonjs/functions/extract-css-var-default-value.js.map +1 -0
- package/lib/edge/commonjs/functions/transform-style-property.js +3 -1
- package/lib/edge/commonjs/functions/transform-style-property.js.map +1 -1
- package/lib/edge/commonjs/helpers/cookie.js +12 -2
- package/lib/edge/commonjs/helpers/cookie.js.map +1 -1
- package/lib/edge/module/blocks/embed/component-info.js +3 -2
- package/lib/edge/module/blocks/embed/component-info.js.map +1 -1
- package/lib/edge/module/blocks/image/component-info.js +1 -1
- package/lib/edge/module/blocks/image/component-info.js.map +1 -1
- package/lib/edge/module/blocks/text/text.js +1 -1
- package/lib/edge/module/blocks/text/text.js.map +1 -1
- package/lib/edge/module/constants/sdk-version.js +1 -1
- package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
- package/lib/edge/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/edge/module/functions/extract-css-var-default-value.js +13 -0
- package/lib/edge/module/functions/extract-css-var-default-value.js.map +1 -0
- package/lib/edge/module/functions/transform-style-property.js +3 -1
- package/lib/edge/module/functions/transform-style-property.js.map +1 -1
- package/lib/edge/module/helpers/cookie.js +11 -2
- package/lib/edge/module/helpers/cookie.js.map +1 -1
- package/lib/edge/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/edge/typescript/functions/extract-css-var-default-value.d.ts +2 -0
- package/lib/edge/typescript/functions/extract-css-var-default-value.d.ts.map +1 -0
- package/lib/edge/typescript/functions/transform-style-property.d.ts.map +1 -1
- package/lib/edge/typescript/helpers/cookie.d.ts +1 -0
- package/lib/edge/typescript/helpers/cookie.d.ts.map +1 -1
- package/lib/node/commonjs/blocks/embed/component-info.js +3 -2
- package/lib/node/commonjs/blocks/embed/component-info.js.map +1 -1
- package/lib/node/commonjs/blocks/image/component-info.js +1 -1
- package/lib/node/commonjs/blocks/image/component-info.js.map +1 -1
- package/lib/node/commonjs/blocks/text/text.js +1 -1
- package/lib/node/commonjs/constants/sdk-version.js +1 -1
- package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js +4 -18
- package/lib/node/commonjs/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/node/commonjs/functions/extract-css-var-default-value.js +19 -0
- package/lib/node/commonjs/functions/extract-css-var-default-value.js.map +1 -0
- package/lib/node/commonjs/functions/transform-style-property.js +3 -1
- package/lib/node/commonjs/functions/transform-style-property.js.map +1 -1
- package/lib/node/commonjs/helpers/cookie.js +12 -2
- package/lib/node/commonjs/helpers/cookie.js.map +1 -1
- package/lib/node/module/blocks/embed/component-info.js +3 -2
- package/lib/node/module/blocks/embed/component-info.js.map +1 -1
- package/lib/node/module/blocks/image/component-info.js +1 -1
- package/lib/node/module/blocks/image/component-info.js.map +1 -1
- package/lib/node/module/blocks/text/text.js +1 -1
- package/lib/node/module/blocks/text/text.js.map +1 -1
- package/lib/node/module/constants/sdk-version.js +1 -1
- package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js +5 -18
- package/lib/node/module/functions/evaluate/node-runtime/safeDynamicRequire.js.map +1 -1
- package/lib/node/module/functions/extract-css-var-default-value.js +13 -0
- package/lib/node/module/functions/extract-css-var-default-value.js.map +1 -0
- package/lib/node/module/functions/transform-style-property.js +3 -1
- package/lib/node/module/functions/transform-style-property.js.map +1 -1
- package/lib/node/module/helpers/cookie.js +11 -2
- package/lib/node/module/helpers/cookie.js.map +1 -1
- package/lib/node/typescript/constants/sdk-version.d.ts +1 -1
- package/lib/node/typescript/functions/extract-css-var-default-value.d.ts +2 -0
- package/lib/node/typescript/functions/extract-css-var-default-value.d.ts.map +1 -0
- package/lib/node/typescript/functions/transform-style-property.d.ts.map +1 -1
- package/lib/node/typescript/helpers/cookie.d.ts +1 -0
- package/lib/node/typescript/helpers/cookie.d.ts.map +1 -1
- package/package.json +10 -7
- package/src/blocks/BaseText.tsx +17 -0
- package/src/blocks/accordion/accordion.tsx +181 -0
- package/src/blocks/accordion/accordion.types.ts +12 -0
- package/src/blocks/accordion/component-info.ts +124 -0
- package/src/blocks/accordion/helpers.ts +3 -0
- package/src/blocks/accordion/index.ts +1 -0
- package/src/blocks/button/button.tsx +56 -0
- package/src/blocks/button/button.types.ts +7 -0
- package/src/blocks/button/component-info.ts +35 -0
- package/src/blocks/button/index.ts +1 -0
- package/src/blocks/columns/columns.tsx +199 -0
- package/src/blocks/columns/columns.types.ts +14 -0
- package/src/blocks/columns/component-info.ts +219 -0
- package/src/blocks/columns/helpers.ts +3 -0
- package/src/blocks/columns/index.ts +1 -0
- package/src/blocks/custom-code/component-info.ts +24 -0
- package/src/blocks/custom-code/custom-code.tsx +71 -0
- package/src/blocks/custom-code/index.ts +1 -0
- package/src/blocks/embed/component-info.ts +40 -0
- package/src/blocks/embed/embed.tsx +62 -0
- package/src/blocks/embed/helpers.ts +2 -0
- package/src/blocks/embed/index.ts +1 -0
- package/src/blocks/form/form/component-info.ts +233 -0
- package/src/blocks/form/form/form.tsx +324 -0
- package/src/blocks/form/form/index.ts +1 -0
- package/src/blocks/form/input/component-info.ts +47 -0
- package/src/blocks/form/input/index.ts +1 -0
- package/src/blocks/form/input/input.tsx +49 -0
- package/src/blocks/form/select/component-info.ts +44 -0
- package/src/blocks/form/select/index.ts +1 -0
- package/src/blocks/form/select/select.tsx +54 -0
- package/src/blocks/form/submit-button/component-info.ts +27 -0
- package/src/blocks/form/submit-button/index.ts +1 -0
- package/src/blocks/form/submit-button/submit-button.tsx +34 -0
- package/src/blocks/fragment/component-info.ts +8 -0
- package/src/blocks/fragment/fragment.tsx +18 -0
- package/src/blocks/fragment/fragment.types.ts +5 -0
- package/src/blocks/fragment/index.ts +1 -0
- package/src/blocks/helpers.ts +43 -0
- package/src/blocks/image/component-info.ts +129 -0
- package/src/blocks/image/image.helpers.ts +47 -0
- package/src/blocks/image/image.tsx +65 -0
- package/src/blocks/image/image.types.ts +20 -0
- package/src/blocks/image/index.ts +1 -0
- package/src/blocks/img/component-info.ts +16 -0
- package/src/blocks/img/img.tsx +55 -0
- package/src/blocks/img/index.ts +1 -0
- package/src/blocks/raw-text/component-info.ts +11 -0
- package/src/blocks/raw-text/index.ts +1 -0
- package/src/blocks/raw-text/raw-text.tsx +1 -0
- package/src/blocks/section/component-info.ts +41 -0
- package/src/blocks/section/index.ts +1 -0
- package/src/blocks/section/section.tsx +39 -0
- package/src/blocks/section/section.types.ts +6 -0
- package/src/blocks/slot/component-info.ts +15 -0
- package/src/blocks/slot/index.ts +1 -0
- package/src/blocks/slot/slot.tsx +42 -0
- package/src/blocks/symbol/component-info.ts +35 -0
- package/src/blocks/symbol/index.ts +1 -0
- package/src/blocks/symbol/symbol.helpers.ts +47 -0
- package/src/blocks/symbol/symbol.tsx +100 -0
- package/src/blocks/symbol/symbol.types.ts +17 -0
- package/src/blocks/tabs/component-info.ts +139 -0
- package/src/blocks/tabs/index.ts +1 -0
- package/src/blocks/tabs/tabs.tsx +79 -0
- package/src/blocks/tabs/tabs.types.ts +13 -0
- package/src/blocks/text/component-info.ts +20 -0
- package/src/blocks/text/index.ts +1 -0
- package/src/blocks/text/text.tsx +105 -0
- package/src/blocks/text/text.types.ts +4 -0
- package/src/blocks/textarea/component-info.ts +38 -0
- package/src/blocks/textarea/index.ts +1 -0
- package/src/blocks/textarea/textarea.tsx +41 -0
- package/src/blocks/video/component-info.ts +83 -0
- package/src/blocks/video/index.ts +1 -0
- package/src/blocks/video/video.tsx +70 -0
- package/src/blocks/video/video.types.ts +21 -0
- package/src/components/block/animator.ts +220 -0
- package/src/components/block/block.helpers.ts +124 -0
- package/src/components/block/block.tsx +232 -0
- package/src/components/block/components/block-styles.tsx +136 -0
- package/src/components/block/components/block-wrapper.tsx +52 -0
- package/src/components/block/components/component-ref/component-ref.helpers.ts +55 -0
- package/src/components/block/components/component-ref/component-ref.tsx +66 -0
- package/src/components/block/components/interactive-element.tsx +53 -0
- package/src/components/block/components/repeated-block.tsx +37 -0
- package/src/components/block/types.ts +6 -0
- package/src/components/blocks/blocks-wrapper.tsx +93 -0
- package/src/components/blocks/blocks.tsx +57 -0
- package/src/components/blocks/blocks.types.ts +7 -0
- package/src/components/blocks/index.ts +1 -0
- package/src/components/content/components/enable-editor.tsx +472 -0
- package/src/components/content/components/styles.helpers.ts +101 -0
- package/src/components/content/components/styles.tsx +42 -0
- package/src/components/content/content.helpers.ts +40 -0
- package/src/components/content/content.tsx +150 -0
- package/src/components/content/content.types.ts +13 -0
- package/src/components/content/contentProps.types.ts +17 -0
- package/src/components/content/index.ts +1 -0
- package/src/components/content/wrap-component-ref.ts +6 -0
- package/src/components/content-variants/content-variants.tsx +146 -0
- package/src/components/content-variants/content-variants.types.ts +84 -0
- package/src/components/content-variants/helpers.ts +72 -0
- package/src/components/content-variants/index.ts +1 -0
- package/src/components/content-variants/inlined-fns.ts +22 -0
- package/src/components/dynamic-div.tsx +30 -0
- package/src/components/dynamic-renderer/dynamic-renderer.helpers.ts +7 -0
- package/src/components/dynamic-renderer/dynamic-renderer.tsx +47 -0
- package/src/components/error-boundary.tsx +38 -0
- package/src/components/inlined-script.tsx +10 -0
- package/src/components/inlined-styles.tsx +10 -0
- package/src/constants/builder-registered-components.ts +59 -0
- package/src/constants/device-sizes.ts +59 -0
- package/src/constants/extra-components.ts +1 -0
- package/src/constants/sdk-version.ts +1 -0
- package/src/constants/target.ts +3 -0
- package/src/context/builder.context.ts +15 -0
- package/src/context/components.context.ts +3 -0
- package/src/context/index.ts +1 -0
- package/src/context/types.ts +38 -0
- package/src/functions/apply-patch-with-mutation.ts +61 -0
- package/src/functions/camel-to-kebab-case.ts +1 -0
- package/src/functions/deopt.ts +6 -0
- package/src/functions/evaluate/browser-runtime/browser.ts +61 -0
- package/src/functions/evaluate/browser-runtime/index.ts +1 -0
- package/src/functions/evaluate/choose-eval.ts +23 -0
- package/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
- package/src/functions/evaluate/edge-runtime/edge-runtime.ts +89 -0
- package/src/functions/evaluate/edge-runtime/index.ts +1 -0
- package/src/functions/evaluate/evaluate.ts +76 -0
- package/src/functions/evaluate/helpers.ts +56 -0
- package/src/functions/evaluate/index.ts +1 -0
- package/src/functions/evaluate/node-runtime/index.ts +1 -0
- package/src/functions/evaluate/node-runtime/init.ts +33 -0
- package/src/functions/evaluate/node-runtime/node-runtime.ts +176 -0
- package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +14 -0
- package/src/functions/evaluate/placeholder-runtime.ts +4 -0
- package/src/functions/evaluate/should-force-browser-runtime-in-node.ts +16 -0
- package/src/functions/event-handler-name.ts +4 -0
- package/src/functions/extract-css-var-default-value.ts +12 -0
- package/src/functions/extract-text-styles.ts +24 -0
- package/src/functions/fast-clone.ts +4 -0
- package/src/functions/fetch-builder-props.ts +75 -0
- package/src/functions/get-block-actions-handler.ts +17 -0
- package/src/functions/get-block-actions.ts +35 -0
- package/src/functions/get-block-component-options.ts +7 -0
- package/src/functions/get-block-properties.ts +62 -0
- package/src/functions/get-builder-search-params/index.ts +33 -0
- package/src/functions/get-class-prop-name.ts +15 -0
- package/src/functions/get-content/generate-content-url.ts +88 -0
- package/src/functions/get-content/index.ts +99 -0
- package/src/functions/get-content/types.ts +157 -0
- package/src/functions/get-env.ts +5 -0
- package/src/functions/get-fetch.ts +11 -0
- package/src/functions/get-global-this.ts +16 -0
- package/src/functions/get-processed-block.ts +70 -0
- package/src/functions/get-style.ts +38 -0
- package/src/functions/get.ts +4 -0
- package/src/functions/is-browser.ts +3 -0
- package/src/functions/is-edge-runtime.ts +9 -0
- package/src/functions/is-editing.ts +8 -0
- package/src/functions/is-from-trusted-host.ts +11 -0
- package/src/functions/is-iframe.ts +4 -0
- package/src/functions/is-node-runtime.ts +8 -0
- package/src/functions/is-previewing.ts +16 -0
- package/src/functions/on-change.ts +29 -0
- package/src/functions/register-component.ts +30 -0
- package/src/functions/register.ts +44 -0
- package/src/functions/set-editor-settings.ts +15 -0
- package/src/functions/set.ts +14 -0
- package/src/functions/track/helpers.ts +51 -0
- package/src/functions/track/index.ts +131 -0
- package/src/functions/track/interaction.ts +63 -0
- package/src/functions/transform-block-properties.ts +33 -0
- package/src/functions/transform-block.ts +30 -0
- package/src/functions/transform-style-property.ts +298 -0
- package/src/helpers/ab-tests.ts +166 -0
- package/src/helpers/canTrack.ts +2 -0
- package/src/helpers/cookie.ts +109 -0
- package/src/helpers/css.ts +33 -0
- package/src/helpers/flatten.ts +41 -0
- package/src/helpers/localStorage.ts +36 -0
- package/src/helpers/logger.ts +7 -0
- package/src/helpers/nullable.ts +2 -0
- package/src/helpers/omit.ts +7 -0
- package/src/helpers/preview-lru-cache/get.ts +4 -0
- package/src/helpers/preview-lru-cache/helpers.ts +1 -0
- package/src/helpers/preview-lru-cache/init.ts +7 -0
- package/src/helpers/preview-lru-cache/set.ts +12 -0
- package/src/helpers/preview-lru-cache/types.ts +1 -0
- package/src/helpers/search/search.ts +18 -0
- package/src/helpers/sessionId.ts +37 -0
- package/src/helpers/subscribe-to-editor.ts +95 -0
- package/src/helpers/time.ts +2 -0
- package/src/helpers/url.ts +15 -0
- package/src/helpers/uuid.ts +17 -0
- package/src/helpers/visitorId.ts +37 -0
- package/src/index-helpers/blocks-exports.ts +16 -0
- package/src/index-helpers/top-of-file.ts +2 -0
- package/src/index.ts +15 -0
- package/src/scripts/init-editing.ts +119 -0
- package/src/server-index.ts +43 -0
- package/src/types/api-version.ts +2 -0
- package/src/types/builder-block.ts +89 -0
- package/src/types/builder-content.ts +47 -0
- package/src/types/builder-props.ts +12 -0
- package/src/types/can-track.ts +3 -0
- package/src/types/components.ts +119 -0
- package/src/types/deep-partial.ts +1 -0
- package/src/types/element.ts +57 -0
- package/src/types/enforced-partials.ts +19 -0
- package/src/types/input.ts +123 -0
- package/src/types/targets.ts +1 -0
- package/src/types/typescript.ts +9 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Image',
|
|
4
|
+
static: true,
|
|
5
|
+
image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
|
|
6
|
+
defaultStyles: {
|
|
7
|
+
position: 'relative',
|
|
8
|
+
minHeight: '20px',
|
|
9
|
+
minWidth: '20px',
|
|
10
|
+
overflow: 'hidden'
|
|
11
|
+
},
|
|
12
|
+
canHaveChildren: true,
|
|
13
|
+
inputs: [{
|
|
14
|
+
name: 'image',
|
|
15
|
+
type: 'file',
|
|
16
|
+
bubble: true,
|
|
17
|
+
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'webp'],
|
|
18
|
+
required: true,
|
|
19
|
+
defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a',
|
|
20
|
+
onChange: (options: Map<string, any>): void | Promise<void> => {
|
|
21
|
+
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
22
|
+
options.delete('srcset');
|
|
23
|
+
options.delete('noWebp');
|
|
24
|
+
function loadImage(url: string, timeout = 60000): Promise<HTMLImageElement> {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const img = document.createElement('img');
|
|
27
|
+
let loaded = false;
|
|
28
|
+
img.onload = () => {
|
|
29
|
+
loaded = true;
|
|
30
|
+
resolve(img);
|
|
31
|
+
};
|
|
32
|
+
img.addEventListener('error', event => {
|
|
33
|
+
console.warn('Image load failed', event.error);
|
|
34
|
+
reject(event.error);
|
|
35
|
+
});
|
|
36
|
+
img.src = url;
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
if (!loaded) {
|
|
39
|
+
reject(new Error('Image load timed out'));
|
|
40
|
+
}
|
|
41
|
+
}, timeout);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function round(num: number) {
|
|
45
|
+
return Math.round(num * 1000) / 1000;
|
|
46
|
+
}
|
|
47
|
+
const value = options.get('image');
|
|
48
|
+
const aspectRatio = options.get('aspectRatio');
|
|
49
|
+
|
|
50
|
+
// For SVG images - don't render as webp, keep them as SVG
|
|
51
|
+
fetch(value).then(res => res.blob()).then(blob => {
|
|
52
|
+
if (blob.type.includes('svg')) {
|
|
53
|
+
options.set('noWebp', true);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
57
|
+
return loadImage(value).then(img => {
|
|
58
|
+
const possiblyUpdatedAspectRatio = options.get('aspectRatio');
|
|
59
|
+
if (options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
60
|
+
if (img.width && img.height) {
|
|
61
|
+
options.set('aspectRatio', round(img.height / img.width));
|
|
62
|
+
options.set('height', img.height);
|
|
63
|
+
options.set('width', img.width);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
name: 'backgroundSize',
|
|
71
|
+
type: 'text',
|
|
72
|
+
defaultValue: 'cover',
|
|
73
|
+
enum: [{
|
|
74
|
+
label: 'contain',
|
|
75
|
+
value: 'contain',
|
|
76
|
+
helperText: 'The image should never get cropped'
|
|
77
|
+
}, {
|
|
78
|
+
label: 'cover',
|
|
79
|
+
value: 'cover',
|
|
80
|
+
helperText: "The image should fill it's box, cropping when needed"
|
|
81
|
+
}]
|
|
82
|
+
}, {
|
|
83
|
+
name: 'backgroundPosition',
|
|
84
|
+
type: 'text',
|
|
85
|
+
defaultValue: 'center',
|
|
86
|
+
enum: ['center', 'top', 'left', 'right', 'bottom', 'top left', 'top right', 'bottom left', 'bottom right']
|
|
87
|
+
}, {
|
|
88
|
+
name: 'altText',
|
|
89
|
+
type: 'string',
|
|
90
|
+
helperText: 'Text to display when the user has images off'
|
|
91
|
+
}, {
|
|
92
|
+
name: 'height',
|
|
93
|
+
type: 'number',
|
|
94
|
+
hideFromUI: true
|
|
95
|
+
}, {
|
|
96
|
+
name: 'width',
|
|
97
|
+
type: 'number',
|
|
98
|
+
hideFromUI: true
|
|
99
|
+
}, {
|
|
100
|
+
name: 'sizes',
|
|
101
|
+
type: 'string',
|
|
102
|
+
hideFromUI: true
|
|
103
|
+
}, {
|
|
104
|
+
name: 'srcset',
|
|
105
|
+
type: 'string',
|
|
106
|
+
hideFromUI: true
|
|
107
|
+
}, {
|
|
108
|
+
name: 'lazy',
|
|
109
|
+
type: 'boolean',
|
|
110
|
+
defaultValue: true,
|
|
111
|
+
hideFromUI: true
|
|
112
|
+
}, {
|
|
113
|
+
name: 'fitContent',
|
|
114
|
+
type: 'boolean',
|
|
115
|
+
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
116
|
+
defaultValue: true
|
|
117
|
+
}, {
|
|
118
|
+
name: 'highPriority',
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
advanced: true,
|
|
121
|
+
helperText: 'Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page.'
|
|
122
|
+
}, {
|
|
123
|
+
name: 'aspectRatio',
|
|
124
|
+
type: 'number',
|
|
125
|
+
helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
|
|
126
|
+
advanced: true,
|
|
127
|
+
defaultValue: 0.7041
|
|
128
|
+
}]
|
|
129
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Taken from (and modified) the shopify theme script repo
|
|
2
|
+
// https://github.com/Shopify/theme-scripts/blob/bcfb471f2a57d439e2f964a1bb65b67708cc90c3/packages/theme-images/images.js#L59
|
|
3
|
+
function removeProtocol(path: string) {
|
|
4
|
+
return path.replace(/http(s)?:/, '');
|
|
5
|
+
}
|
|
6
|
+
function updateQueryParam(uri = '', key: string, value: string | number | boolean): string {
|
|
7
|
+
const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
|
|
8
|
+
const separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
|
9
|
+
if (uri.match(re)) {
|
|
10
|
+
return uri.replace(re, '$1' + key + '=' + encodeURIComponent(value) + '$2');
|
|
11
|
+
}
|
|
12
|
+
return uri + separator + key + '=' + encodeURIComponent(value);
|
|
13
|
+
}
|
|
14
|
+
function getShopifyImageUrl(src: string, size: string): string | null {
|
|
15
|
+
if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
|
|
16
|
+
return src;
|
|
17
|
+
}
|
|
18
|
+
if (size === 'master') {
|
|
19
|
+
return removeProtocol(src);
|
|
20
|
+
}
|
|
21
|
+
const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
|
|
22
|
+
if (match) {
|
|
23
|
+
const prefix = src.split(match[0]);
|
|
24
|
+
const suffix = match[3];
|
|
25
|
+
const useSize = size.match('x') ? size : `${size}x`;
|
|
26
|
+
return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export function getSrcSet(url: string): string {
|
|
31
|
+
if (!url) {
|
|
32
|
+
return url;
|
|
33
|
+
}
|
|
34
|
+
const sizes = [100, 200, 400, 800, 1200, 1600, 2000];
|
|
35
|
+
if (url.match(/builder\.io/)) {
|
|
36
|
+
let srcUrl = url;
|
|
37
|
+
const widthInSrc = Number(url.split('?width=')[1]);
|
|
38
|
+
if (!isNaN(widthInSrc)) {
|
|
39
|
+
srcUrl = `${srcUrl} ${widthInSrc}w`;
|
|
40
|
+
}
|
|
41
|
+
return sizes.filter(size => size !== widthInSrc).map(size => `${updateQueryParam(url, 'width', size)} ${size}w`).concat([srcUrl]).join(', ');
|
|
42
|
+
}
|
|
43
|
+
if (url.match(/cdn\.shopify\.com/)) {
|
|
44
|
+
return sizes.map(size => [getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(', ');
|
|
45
|
+
}
|
|
46
|
+
return url;
|
|
47
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StyleProp,ImageStyle } from 'react-native';
|
|
3
|
+
import { Image as ReactImage, View } from 'react-native';
|
|
4
|
+
import type { ImageProps } from './image.types';
|
|
5
|
+
|
|
6
|
+
export default function Image(props: ImageProps) {
|
|
7
|
+
const shouldRenderUnwrappedChildren =
|
|
8
|
+
props.fitContent && props.builderBlock?.children?.length;
|
|
9
|
+
|
|
10
|
+
const imageStyle:StyleProp<ImageStyle> = (props.aspectRatio
|
|
11
|
+
? {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
top: 0,
|
|
14
|
+
bottom: 0,
|
|
15
|
+
left: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
}
|
|
18
|
+
: {
|
|
19
|
+
position: 'relative',
|
|
20
|
+
...(props.width ? { width: props.width } : {}),
|
|
21
|
+
...(props.height ? { height: props.height } : {}),
|
|
22
|
+
} ) ;
|
|
23
|
+
|
|
24
|
+
const paddingTop = `${props.aspectRatio * 100}%` as const;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<React.Fragment>
|
|
29
|
+
<ReactImage
|
|
30
|
+
resizeMode={props.backgroundSize || 'contain'}
|
|
31
|
+
style={imageStyle}
|
|
32
|
+
source={{ uri: props.image }}
|
|
33
|
+
/>
|
|
34
|
+
{props.aspectRatio && !shouldRenderUnwrappedChildren ? (
|
|
35
|
+
<View
|
|
36
|
+
style={{
|
|
37
|
+
width: '100%',
|
|
38
|
+
paddingTop,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
) : null}
|
|
42
|
+
</React.Fragment>
|
|
43
|
+
|
|
44
|
+
{shouldRenderUnwrappedChildren && props.children}
|
|
45
|
+
|
|
46
|
+
{!props.fitContent && props.children && (
|
|
47
|
+
// When `fitContent: false`, we wrap image children ssuch that they stretch across the entire image
|
|
48
|
+
<View
|
|
49
|
+
style={{
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
alignItems: 'stretch',
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
top: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
width: '100%',
|
|
57
|
+
height: '100%',
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{props.children}
|
|
61
|
+
</View>
|
|
62
|
+
)}
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
+
export interface ImageProps {
|
|
3
|
+
highPriority?: boolean;
|
|
4
|
+
className?: string;
|
|
5
|
+
image: string;
|
|
6
|
+
sizes?: string;
|
|
7
|
+
lazy?: boolean;
|
|
8
|
+
height?: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
altText?: string;
|
|
11
|
+
backgroundSize?: 'cover' | 'contain';
|
|
12
|
+
backgroundPosition?: string;
|
|
13
|
+
srcset?: string;
|
|
14
|
+
aspectRatio?: number;
|
|
15
|
+
children?: any;
|
|
16
|
+
fitContent?: boolean;
|
|
17
|
+
builderBlock?: BuilderBlock;
|
|
18
|
+
noWebp?: boolean;
|
|
19
|
+
src?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './image'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
// friendlyName?
|
|
4
|
+
name: 'Raw:Img',
|
|
5
|
+
hideFromInsertMenu: true,
|
|
6
|
+
image: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
|
|
7
|
+
inputs: [{
|
|
8
|
+
name: 'image',
|
|
9
|
+
bubble: true,
|
|
10
|
+
type: 'file',
|
|
11
|
+
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'gif', 'webp'],
|
|
12
|
+
required: true
|
|
13
|
+
}],
|
|
14
|
+
noWrap: true,
|
|
15
|
+
static: true
|
|
16
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
ScrollView,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Image,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This import is used by the Svelte SDK. Do not remove.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface ImgProps {
|
|
18
|
+
attributes?: any;
|
|
19
|
+
imgSrc?: string; // TODO(misko): I think this is unused
|
|
20
|
+
image?: string;
|
|
21
|
+
altText?: string;
|
|
22
|
+
backgroundSize?: "cover" | "contain";
|
|
23
|
+
backgroundPosition?:
|
|
24
|
+
| "center"
|
|
25
|
+
| "top"
|
|
26
|
+
| "left"
|
|
27
|
+
| "right"
|
|
28
|
+
| "bottom"
|
|
29
|
+
| "top left"
|
|
30
|
+
| "top right"
|
|
31
|
+
| "bottom left"
|
|
32
|
+
| "bottom right";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
import { isEditing } from "../../functions/is-editing";
|
|
36
|
+
import { filterAttrs } from "../helpers";
|
|
37
|
+
import { setAttrs } from "../helpers";
|
|
38
|
+
|
|
39
|
+
function ImgComponent(props: ImgProps) {
|
|
40
|
+
return (
|
|
41
|
+
<View
|
|
42
|
+
style={{
|
|
43
|
+
objectFit: props.backgroundSize || "cover",
|
|
44
|
+
objectPosition: props.backgroundPosition || "center",
|
|
45
|
+
}}
|
|
46
|
+
key={(isEditing() && props.imgSrc) || "default-key"}
|
|
47
|
+
alt={props.altText}
|
|
48
|
+
src={props.imgSrc || props.image}
|
|
49
|
+
{...{}}
|
|
50
|
+
{...props.attributes}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default ImgComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './img'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './raw-text'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../text/text';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Core:Section',
|
|
4
|
+
static: true,
|
|
5
|
+
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',
|
|
6
|
+
inputs: [{
|
|
7
|
+
name: 'maxWidth',
|
|
8
|
+
type: 'number',
|
|
9
|
+
defaultValue: 1200
|
|
10
|
+
}, {
|
|
11
|
+
name: 'lazyLoad',
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
defaultValue: false,
|
|
14
|
+
advanced: true,
|
|
15
|
+
description: 'Only render this section when in view'
|
|
16
|
+
}],
|
|
17
|
+
defaultStyles: {
|
|
18
|
+
paddingLeft: '20px',
|
|
19
|
+
paddingRight: '20px',
|
|
20
|
+
paddingTop: '50px',
|
|
21
|
+
paddingBottom: '50px',
|
|
22
|
+
marginTop: '0px',
|
|
23
|
+
width: '100vw',
|
|
24
|
+
marginLeft: 'calc(50% - 50vw)'
|
|
25
|
+
},
|
|
26
|
+
canHaveChildren: true,
|
|
27
|
+
defaultChildren: [{
|
|
28
|
+
'@type': '@builder.io/sdk:Element',
|
|
29
|
+
responsiveStyles: {
|
|
30
|
+
large: {
|
|
31
|
+
textAlign: 'center'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
component: {
|
|
35
|
+
name: 'Text',
|
|
36
|
+
options: {
|
|
37
|
+
text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}]
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './section'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
ScrollView,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Image,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import { filterAttrs } from "../helpers";
|
|
13
|
+
import type { SectionProps } from "./section.types";
|
|
14
|
+
import { setAttrs } from "../helpers";
|
|
15
|
+
|
|
16
|
+
function SectionComponent(props: SectionProps) {
|
|
17
|
+
return (
|
|
18
|
+
<View
|
|
19
|
+
{...{}}
|
|
20
|
+
{...props.attributes}
|
|
21
|
+
style={{
|
|
22
|
+
width: "100%",
|
|
23
|
+
alignSelf: "stretch",
|
|
24
|
+
flexGrow: 1,
|
|
25
|
+
boxSizing: "border-box",
|
|
26
|
+
maxWidth: props.maxWidth || 1200,
|
|
27
|
+
display: "flex",
|
|
28
|
+
flexDirection: "column",
|
|
29
|
+
alignItems: "stretch",
|
|
30
|
+
marginLeft: "auto",
|
|
31
|
+
marginRight: "auto",
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{props.children}
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default SectionComponent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Slot',
|
|
4
|
+
isRSC: true,
|
|
5
|
+
description: 'Allow child blocks to be inserted into this content when used as a Symbol',
|
|
6
|
+
docsLink: 'https://www.builder.io/c/docs/symbols-with-blocks',
|
|
7
|
+
image: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56',
|
|
8
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
9
|
+
inputs: [{
|
|
10
|
+
name: 'name',
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: true,
|
|
13
|
+
defaultValue: 'children'
|
|
14
|
+
}]
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './slot'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
ScrollView,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Image,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
|
|
13
|
+
export type DropzoneProps = BuilderDataProps & {
|
|
14
|
+
name: string;
|
|
15
|
+
attributes: any;
|
|
16
|
+
};
|
|
17
|
+
import Blocks from "../../components/blocks/blocks";
|
|
18
|
+
import { deoptSignal } from "../../functions/deopt";
|
|
19
|
+
import type { BuilderBlock } from "../../types/builder-block";
|
|
20
|
+
import type { BuilderDataProps } from "../../types/builder-props";
|
|
21
|
+
|
|
22
|
+
function Slot(props: DropzoneProps) {
|
|
23
|
+
return (
|
|
24
|
+
<View
|
|
25
|
+
style={{
|
|
26
|
+
pointerEvents: "auto",
|
|
27
|
+
}}
|
|
28
|
+
{...(!props.builderContext.context?.symbolId && {
|
|
29
|
+
"builder-slot": props.name,
|
|
30
|
+
})}
|
|
31
|
+
>
|
|
32
|
+
<Blocks
|
|
33
|
+
parent={props.builderContext.context?.symbolId as string}
|
|
34
|
+
path={`symbol.data.${props.name}`}
|
|
35
|
+
context={props.builderContext}
|
|
36
|
+
blocks={props.builderContext.rootState?.[props.name] as BuilderBlock[]}
|
|
37
|
+
/>
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default Slot;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
export const componentInfo: ComponentInfo = {
|
|
3
|
+
name: 'Symbol',
|
|
4
|
+
noWrap: true,
|
|
5
|
+
static: true,
|
|
6
|
+
isRSC: true,
|
|
7
|
+
inputs: [{
|
|
8
|
+
name: 'symbol',
|
|
9
|
+
type: 'uiSymbol'
|
|
10
|
+
}, {
|
|
11
|
+
name: 'dataOnly',
|
|
12
|
+
helperText: "Make this a data symbol that doesn't display any UI",
|
|
13
|
+
type: 'boolean',
|
|
14
|
+
defaultValue: false,
|
|
15
|
+
advanced: true,
|
|
16
|
+
hideFromUI: true
|
|
17
|
+
}, {
|
|
18
|
+
name: 'inheritState',
|
|
19
|
+
helperText: 'Inherit the parent component state and data',
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
defaultValue: false,
|
|
22
|
+
advanced: true
|
|
23
|
+
}, {
|
|
24
|
+
name: 'renderToLiquid',
|
|
25
|
+
helperText: 'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
defaultValue: false,
|
|
28
|
+
advanced: true,
|
|
29
|
+
hideFromUI: true
|
|
30
|
+
}, {
|
|
31
|
+
name: 'useChildren',
|
|
32
|
+
hideFromUI: true,
|
|
33
|
+
type: 'boolean'
|
|
34
|
+
}]
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './symbol'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
+
import { fetchOneEntry } from '../../functions/get-content/index';
|
|
3
|
+
import { logger } from '../../helpers/logger';
|
|
4
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
5
|
+
export interface SymbolInfo {
|
|
6
|
+
model?: string;
|
|
7
|
+
entry?: string;
|
|
8
|
+
data?: any;
|
|
9
|
+
content?: BuilderContent;
|
|
10
|
+
inline?: boolean;
|
|
11
|
+
dynamic?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export const fetchSymbolContent = async ({
|
|
14
|
+
builderContextValue,
|
|
15
|
+
symbol
|
|
16
|
+
}: {
|
|
17
|
+
symbol: SymbolInfo | undefined;
|
|
18
|
+
builderContextValue: BuilderContextInterface;
|
|
19
|
+
}) => {
|
|
20
|
+
/**
|
|
21
|
+
* If:
|
|
22
|
+
* - we have a symbol prop
|
|
23
|
+
* - yet it does not have any content
|
|
24
|
+
* - and we have not already stored content from before
|
|
25
|
+
* - and it has a model name
|
|
26
|
+
*
|
|
27
|
+
* then we want to re-fetch the symbol content.
|
|
28
|
+
*/
|
|
29
|
+
if (symbol?.model &&
|
|
30
|
+
// This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
31
|
+
builderContextValue?.apiKey) {
|
|
32
|
+
return fetchOneEntry({
|
|
33
|
+
model: symbol.model,
|
|
34
|
+
apiKey: builderContextValue.apiKey,
|
|
35
|
+
apiVersion: builderContextValue.apiVersion,
|
|
36
|
+
...(symbol?.entry && {
|
|
37
|
+
query: {
|
|
38
|
+
id: symbol.entry
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}).catch(err => {
|
|
42
|
+
logger.error('Could not fetch symbol content: ', err);
|
|
43
|
+
return undefined;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|