@builder.io/sdk-svelte 0.0.1-9 → 0.0.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 +4 -0
- package/package/CHANGELOG.md +19 -0
- package/package/README.md +19 -0
- package/{src/types/builder-block.js → package/blocks/button/button.lite.d.ts} +0 -0
- package/package/blocks/button/button.lite.tsx +36 -0
- package/package/blocks/button/button.svelte +28 -0
- package/package/blocks/button/button.svelte.d.ts +25 -0
- package/package/blocks/button/component-info.d.ts +2 -0
- package/package/blocks/button/component-info.js +39 -0
- package/{src/types/builder-content.js → package/blocks/columns/columns.lite.d.ts} +0 -0
- package/package/blocks/columns/columns.lite.tsx +139 -0
- package/package/blocks/columns/columns.svelte +109 -0
- package/package/blocks/columns/columns.svelte.d.ts +33 -0
- package/package/blocks/columns/component-info.d.ts +2 -0
- package/package/blocks/columns/component-info.js +241 -0
- package/package/blocks/custom-code/component-info.d.ts +2 -0
- package/package/blocks/custom-code/component-info.js +28 -0
- package/{src/types/components.js → package/blocks/custom-code/custom-code.lite.d.ts} +0 -0
- package/package/blocks/custom-code/custom-code.lite.tsx +70 -0
- package/package/blocks/custom-code/custom-code.svelte +55 -0
- package/package/blocks/custom-code/custom-code.svelte.d.ts +21 -0
- package/package/blocks/embed/component-info.d.ts +2 -0
- package/package/blocks/embed/component-info.js +47 -0
- package/{src/types/deep-partial.js → package/blocks/embed/embed.lite.d.ts} +0 -0
- package/package/blocks/embed/embed.lite.tsx +52 -0
- package/package/blocks/embed/embed.svelte +41 -0
- package/package/blocks/embed/embed.svelte.d.ts +19 -0
- package/package/blocks/embed/helpers.d.ts +1 -0
- package/package/blocks/embed/helpers.js +6 -0
- package/package/blocks/form/component-info.d.ts +2 -0
- package/package/blocks/form/component-info.js +268 -0
- package/{src/types/element.js → package/blocks/form/form.lite.d.ts} +0 -0
- package/package/blocks/form/form.lite.tsx +351 -0
- package/package/blocks/form/form.svelte +259 -0
- package/package/blocks/form/form.svelte.d.ts +70 -0
- package/package/blocks/fragment/component-info.d.ts +2 -0
- package/package/blocks/fragment/component-info.js +8 -0
- package/{src/types/targets.js → package/blocks/fragment/fragment.lite.d.ts} +0 -0
- package/package/blocks/fragment/fragment.lite.tsx +12 -0
- package/package/blocks/fragment/fragment.svelte +5 -0
- package/package/blocks/fragment/fragment.svelte.d.ts +21 -0
- package/package/blocks/image/component-info.d.ts +2 -0
- package/package/blocks/image/component-info.js +153 -0
- package/package/blocks/image/image.helpers.d.ts +1 -0
- package/package/blocks/image/image.helpers.js +56 -0
- package/{src/types/typescript.js → package/blocks/image/image.lite.d.ts} +0 -0
- package/package/blocks/image/image.lite.tsx +148 -0
- package/package/blocks/image/image.svelte +119 -0
- package/package/blocks/image/image.svelte.d.ts +48 -0
- package/package/blocks/img/component-info.d.ts +2 -0
- package/package/blocks/img/component-info.js +18 -0
- package/package/blocks/img/img.lite.d.ts +0 -0
- package/package/blocks/img/img.lite.tsx +48 -0
- package/package/blocks/img/img.svelte +26 -0
- package/package/blocks/img/img.svelte.d.ts +29 -0
- package/package/blocks/input/component-info.d.ts +2 -0
- package/package/blocks/input/component-info.js +72 -0
- package/package/blocks/input/input.lite.d.ts +0 -0
- package/package/blocks/input/input.lite.tsx +34 -0
- package/package/blocks/input/input.svelte +22 -0
- package/package/blocks/input/input.svelte.d.ts +31 -0
- package/package/blocks/raw-text/component-info.d.ts +2 -0
- package/package/blocks/raw-text/component-info.js +13 -0
- package/package/blocks/raw-text/raw-text.lite.d.ts +0 -0
- package/package/blocks/raw-text/raw-text.lite.tsx +15 -0
- package/package/blocks/raw-text/raw-text.svelte +9 -0
- package/package/blocks/raw-text/raw-text.svelte.d.ts +21 -0
- package/package/blocks/section/component-info.d.ts +2 -0
- package/package/blocks/section/component-info.js +46 -0
- package/package/blocks/section/section.lite.d.ts +0 -0
- package/package/blocks/section/section.lite.tsx +30 -0
- package/package/blocks/section/section.svelte +21 -0
- package/package/blocks/section/section.svelte.d.ts +25 -0
- package/package/blocks/select/component-info.d.ts +2 -0
- package/package/blocks/select/component-info.js +56 -0
- package/package/blocks/select/select.lite.d.ts +0 -0
- package/package/blocks/select/select.lite.tsx +34 -0
- package/package/blocks/select/select.svelte +21 -0
- package/package/blocks/select/select.svelte.d.ts +30 -0
- package/package/blocks/submit-button/component-info.d.ts +2 -0
- package/package/blocks/submit-button/component-info.js +29 -0
- package/package/blocks/submit-button/submit-button.lite.d.ts +0 -0
- package/package/blocks/submit-button/submit-button.lite.tsx +15 -0
- package/package/blocks/submit-button/submit-button.svelte +9 -0
- package/package/blocks/submit-button/submit-button.svelte.d.ts +21 -0
- package/package/blocks/symbol/component-info.d.ts +2 -0
- package/package/blocks/symbol/component-info.js +40 -0
- package/package/blocks/symbol/symbol.lite.d.ts +0 -0
- package/package/blocks/symbol/symbol.lite.tsx +92 -0
- package/package/blocks/symbol/symbol.svelte +66 -0
- package/package/blocks/symbol/symbol.svelte.d.ts +35 -0
- package/package/blocks/text/component-info.d.ts +2 -0
- package/package/blocks/text/component-info.js +21 -0
- package/package/blocks/text/text.lite.d.ts +0 -0
- package/package/blocks/text/text.lite.tsx +11 -0
- package/package/blocks/text/text.svelte +6 -0
- package/package/blocks/text/text.svelte.d.ts +19 -0
- package/package/blocks/textarea/component-info.d.ts +2 -0
- package/package/blocks/textarea/component-info.js +44 -0
- package/package/blocks/textarea/textarea.lite.d.ts +0 -0
- package/package/blocks/textarea/textarea.lite.tsx +19 -0
- package/package/blocks/textarea/textarea.svelte +10 -0
- package/package/blocks/textarea/textarea.svelte.d.ts +27 -0
- package/package/blocks/util.d.ts +1 -0
- package/package/blocks/util.js +4 -0
- package/package/blocks/video/component-info.d.ts +2 -0
- package/package/blocks/video/component-info.js +103 -0
- package/package/blocks/video/video.lite.d.ts +0 -0
- package/package/blocks/video/video.lite.tsx +92 -0
- package/package/blocks/video/video.svelte +63 -0
- package/package/blocks/video/video.svelte.d.ts +41 -0
- package/package/components/render-block/block-styles.lite.d.ts +0 -0
- package/package/components/render-block/block-styles.lite.tsx +60 -0
- package/package/components/render-block/block-styles.svelte +45 -0
- package/package/components/render-block/block-styles.svelte.d.ts +23 -0
- package/package/components/render-block/render-block.helpers.d.ts +1 -0
- package/package/components/render-block/render-block.helpers.js +24 -0
- package/package/components/render-block/render-block.lite.d.ts +0 -0
- package/package/components/render-block/render-block.lite.tsx +216 -0
- package/package/components/render-block/render-block.svelte +185 -0
- package/package/components/render-block/render-block.svelte.d.ts +23 -0
- package/package/components/render-block/render-component.lite.d.ts +0 -0
- package/package/components/render-block/render-component.lite.tsx +33 -0
- package/package/components/render-block/render-component.svelte +24 -0
- package/package/components/render-block/render-component.svelte.d.ts +27 -0
- package/package/components/render-block/render-repeated-block.lite.d.ts +0 -0
- package/package/components/render-block/render-repeated-block.lite.tsx +49 -0
- package/package/components/render-block/render-repeated-block.svelte +36 -0
- package/package/components/render-block/render-repeated-block.svelte.d.ts +23 -0
- package/package/components/render-block/types.d.ts +6 -0
- package/package/components/render-block/types.js +2 -0
- package/package/components/render-blocks.lite.d.ts +0 -0
- package/package/components/render-blocks.lite.tsx +91 -0
- package/package/components/render-blocks.svelte +73 -0
- package/package/components/render-blocks.svelte.d.ts +24 -0
- package/package/components/render-content/components/render-styles.lite.d.ts +0 -0
- package/package/components/render-content/components/render-styles.lite.tsx +86 -0
- package/package/components/render-content/components/render-styles.svelte +61 -0
- package/package/components/render-content/components/render-styles.svelte.d.ts +29 -0
- package/package/components/render-content/index.d.ts +1 -0
- package/package/components/render-content/index.js +1 -0
- package/package/components/render-content/render-content.lite.d.ts +0 -0
- package/package/components/render-content/render-content.lite.tsx +356 -0
- package/package/components/render-content/render-content.svelte +260 -0
- package/package/components/render-content/render-content.svelte.d.ts +36 -0
- package/package/components/render-inlined-styles.lite.d.ts +0 -0
- package/package/components/render-inlined-styles.lite.tsx +27 -0
- package/package/components/render-inlined-styles.svelte +19 -0
- package/package/components/render-inlined-styles.svelte.d.ts +19 -0
- package/package/constants/builder-registered-components.d.ts +6 -0
- package/package/constants/builder-registered-components.js +36 -0
- package/package/constants/device-sizes.d.ts +2 -0
- package/package/constants/device-sizes.js +18 -0
- package/package/constants/target.d.ts +2 -0
- package/package/constants/target.js +2 -0
- package/package/context/builder.context.d.ts +11 -0
- package/package/context/builder.context.js +11 -0
- package/package/context/types.d.ts +16 -0
- package/package/context/types.js +3 -0
- package/package/functions/camel-to-kebab-case.d.ts +1 -0
- package/package/functions/camel-to-kebab-case.js +1 -0
- package/package/functions/convert-style-object.d.ts +1 -0
- package/package/functions/convert-style-object.js +3 -0
- package/package/functions/evaluate.d.ts +5 -0
- package/package/functions/evaluate.js +25 -0
- package/package/functions/event-handler-name.d.ts +1 -0
- package/package/functions/event-handler-name.js +4 -0
- package/package/functions/get-block-actions.d.ts +9 -0
- package/package/functions/get-block-actions.js +21 -0
- package/package/functions/get-block-component-options.d.ts +2 -0
- package/package/functions/get-block-component-options.js +11 -0
- package/package/functions/get-block-properties.d.ts +5 -0
- package/package/functions/get-block-properties.js +10 -0
- package/package/functions/get-block-styles.d.ts +2 -0
- package/package/functions/get-block-styles.js +21 -0
- package/package/functions/get-block-tag.d.ts +3 -0
- package/package/functions/get-block-tag.js +4 -0
- package/package/functions/get-builder-search-params/fn.test.d.ts +1 -0
- package/package/functions/get-builder-search-params/fn.test.js +13 -0
- package/package/functions/get-builder-search-params/index.d.ts +6 -0
- package/package/functions/get-builder-search-params/index.js +29 -0
- package/package/functions/get-content/ab-testing.d.ts +3 -0
- package/package/functions/get-content/ab-testing.js +40 -0
- package/package/functions/get-content/fn.test.d.ts +1 -0
- package/package/functions/get-content/fn.test.js +31 -0
- package/package/functions/get-content/index.d.ts +9 -0
- package/package/functions/get-content/index.js +42 -0
- package/package/functions/get-content/types.d.ts +26 -0
- package/package/functions/get-content/types.js +1 -0
- package/package/functions/get-fetch.d.ts +1 -0
- package/package/functions/get-fetch.js +9 -0
- package/package/functions/get-global-this.d.ts +1 -0
- package/package/functions/get-global-this.js +15 -0
- package/package/functions/get-processed-block.d.ts +10 -0
- package/package/functions/get-processed-block.js +29 -0
- package/package/functions/get-processed-block.test.d.ts +1 -0
- package/package/functions/get-processed-block.test.js +32 -0
- package/package/functions/if-target.d.ts +7 -0
- package/package/functions/if-target.js +10 -0
- package/package/functions/is-browser.d.ts +1 -0
- package/package/functions/is-browser.js +3 -0
- package/package/functions/is-editing.d.ts +1 -0
- package/package/functions/is-editing.js +4 -0
- package/package/functions/is-iframe.d.ts +1 -0
- package/package/functions/is-iframe.js +4 -0
- package/package/functions/is-previewing.d.ts +1 -0
- package/package/functions/is-previewing.js +11 -0
- package/package/functions/mark-mutable.d.ts +2 -0
- package/package/functions/mark-mutable.js +6 -0
- package/package/functions/on-change.d.ts +7 -0
- package/package/functions/on-change.js +28 -0
- package/package/functions/on-change.test.d.ts +1 -0
- package/package/functions/on-change.test.js +20 -0
- package/package/functions/register-component.d.ts +14 -0
- package/package/functions/register-component.js +42 -0
- package/package/functions/register.d.ts +16 -0
- package/package/functions/register.js +29 -0
- package/package/functions/sanitize-styles.d.ts +4 -0
- package/package/functions/sanitize-styles.js +6 -0
- package/package/functions/set-editor-settings.d.ts +4 -0
- package/package/functions/set-editor-settings.js +12 -0
- package/package/functions/set.d.ts +7 -0
- package/package/functions/set.js +21 -0
- package/package/functions/set.test.d.ts +1 -0
- package/package/functions/set.test.js +16 -0
- package/package/functions/track.d.ts +21 -0
- package/package/functions/track.js +49 -0
- package/package/functions/transform-block.d.ts +2 -0
- package/package/functions/transform-block.js +5 -0
- package/package/helpers/cookie.d.ts +9 -0
- package/package/helpers/cookie.js +55 -0
- package/package/helpers/css.d.ts +1 -0
- package/package/helpers/css.js +9 -0
- package/package/helpers/flatten.d.ts +6 -0
- package/package/helpers/flatten.js +19 -0
- package/package/helpers/localStorage.d.ts +9 -0
- package/package/helpers/localStorage.js +23 -0
- package/package/helpers/nullable.d.ts +2 -0
- package/package/helpers/nullable.js +1 -0
- package/package/helpers/sessionId.d.ts +7 -0
- package/package/helpers/sessionId.js +20 -0
- package/package/helpers/time.d.ts +1 -0
- package/package/helpers/time.js +2 -0
- package/package/helpers/url.d.ts +6 -0
- package/package/helpers/url.js +12 -0
- package/package/helpers/url.test.d.ts +1 -0
- package/package/helpers/url.test.js +15 -0
- package/package/helpers/uuid.d.ts +8 -0
- package/package/helpers/uuid.js +15 -0
- package/package/helpers/visitorId.d.ts +8 -0
- package/package/helpers/visitorId.js +26 -0
- package/package/index-helpers/blocks-exports.d.ts +10 -0
- package/package/index-helpers/blocks-exports.js +10 -0
- package/package/index-helpers/top-of-file.d.ts +1 -0
- package/package/index-helpers/top-of-file.js +4 -0
- package/package/index.d.ts +10 -0
- package/package/index.js +10 -0
- package/package/scripts/init-editing.d.ts +2 -0
- package/package/scripts/init-editing.js +84 -0
- package/package/types/builder-block.d.ts +57 -0
- package/package/types/builder-block.js +1 -0
- package/package/types/builder-content.d.ts +38 -0
- package/package/types/builder-content.js +1 -0
- package/package/types/can-track.d.ts +3 -0
- package/package/types/can-track.js +1 -0
- package/package/types/components.d.ts +177 -0
- package/package/types/components.js +1 -0
- package/package/types/deep-partial.d.ts +3 -0
- package/package/types/deep-partial.js +1 -0
- package/package/types/element.d.ts +59 -0
- package/package/types/element.js +1 -0
- package/package/types/targets.d.ts +3 -0
- package/package/types/targets.js +1 -0
- package/package/types/typescript.d.ts +4 -0
- package/package/types/typescript.js +1 -0
- package/package.json +31 -8
- package/src/blocks/button/button.svelte +0 -49
- package/src/blocks/button/component-info.js +0 -41
- package/src/blocks/columns/columns.svelte +0 -103
- package/src/blocks/columns/component-info.js +0 -217
- package/src/blocks/custom-code/component-info.js +0 -31
- package/src/blocks/custom-code/custom-code.svelte +0 -64
- package/src/blocks/embed/component-info.js +0 -24
- package/src/blocks/embed/embed.svelte +0 -63
- package/src/blocks/form/component-info.js +0 -262
- package/src/blocks/form/form.svelte +0 -333
- package/src/blocks/fragment/component-info.js +0 -11
- package/src/blocks/fragment/fragment.svelte +0 -28
- package/src/blocks/image/component-info.js +0 -104
- package/src/blocks/image/image.svelte +0 -117
- package/src/blocks/img/component-info.js +0 -20
- package/src/blocks/img/img.svelte +0 -36
- package/src/blocks/input/component-info.js +0 -74
- package/src/blocks/input/input.svelte +0 -35
- package/src/blocks/raw-text/component-info.js +0 -16
- package/src/blocks/raw-text/raw-text.svelte +0 -29
- package/src/blocks/section/component-info.js +0 -49
- package/src/blocks/section/section.svelte +0 -36
- package/src/blocks/select/component-info.js +0 -59
- package/src/blocks/select/select.svelte +0 -41
- package/src/blocks/submit-button/component-info.js +0 -28
- package/src/blocks/submit-button/submit-button.svelte +0 -33
- package/src/blocks/symbol/component-info.js +0 -42
- package/src/blocks/symbol/symbol.svelte +0 -54
- package/src/blocks/text/component-info.js +0 -24
- package/src/blocks/text/text.svelte +0 -28
- package/src/blocks/textarea/component-info.js +0 -47
- package/src/blocks/textarea/textarea.svelte +0 -32
- package/src/blocks/video/component-info.js +0 -106
- package/src/blocks/video/video.svelte +0 -45
- package/src/components/error-boundary.svelte +0 -26
- package/src/components/render-block/block-styles.svelte +0 -51
- package/src/components/render-block/render-block.helpers.js +0 -23
- package/src/components/render-block/render-block.svelte +0 -174
- package/src/components/render-blocks.svelte +0 -82
- package/src/components/render-content/components/render-styles.svelte +0 -90
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/render-content.svelte +0 -252
- package/src/components/render-inlined-styles.svelte +0 -51
- package/src/constants/builder-registered-components.js +0 -45
- package/src/constants/device-sizes.js +0 -39
- package/src/constants/target.js +0 -4
- package/src/context/builder.context.js +0 -8
- package/src/functions/evaluate.js +0 -28
- package/src/functions/event-handler-name.js +0 -7
- package/src/functions/fast-clone.js +0 -4
- package/src/functions/get-block-actions.js +0 -23
- package/src/functions/get-block-component-options.js +0 -23
- package/src/functions/get-block-properties.js +0 -29
- package/src/functions/get-block-styles.js +0 -31
- package/src/functions/get-block-tag.js +0 -6
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-builder-search-params/index.js +0 -22
- package/src/functions/get-content/fn.test.js +0 -31
- package/src/functions/get-content/index.js +0 -138
- package/src/functions/get-fetch.js +0 -34
- package/src/functions/get-global-this.js +0 -18
- package/src/functions/get-processed-block.js +0 -46
- package/src/functions/get-processed-block.test.js +0 -31
- package/src/functions/if-target.js +0 -15
- package/src/functions/is-browser.js +0 -6
- package/src/functions/is-editing.js +0 -7
- package/src/functions/is-iframe.js +0 -7
- package/src/functions/is-previewing.js +0 -14
- package/src/functions/macro-eval.js +0 -5
- package/src/functions/on-change.js +0 -27
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/previewing-model-name.js +0 -11
- package/src/functions/register-component.js +0 -70
- package/src/functions/register.js +0 -29
- package/src/functions/set-editor-settings.js +0 -15
- package/src/functions/set.js +0 -11
- package/src/functions/set.test.js +0 -16
- package/src/functions/track.js +0 -22
- package/src/functions/transform-block.js +0 -6
- package/src/index-helpers/blocks-exports.js +0 -20
- package/src/index-helpers/top-of-file.js +0 -4
- package/src/index.js +0 -10
- package/src/scripts/init-editing.js +0 -80
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type RenderBlockProps = {
|
|
3
|
+
blocks?: BuilderBlock[];
|
|
4
|
+
parent?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
};
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { getContext, setContext } from "svelte";
|
|
11
|
+
|
|
12
|
+
import BuilderContext from "../context/builder.context.js";
|
|
13
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
14
|
+
import { BuilderBlock } from "../types/builder-block.js";
|
|
15
|
+
import BlockStyles from "./render-block/block-styles.svelte";
|
|
16
|
+
import RenderBlock from "./render-block/render-block.svelte";
|
|
17
|
+
|
|
18
|
+
export let blocks: RenderBlockProps["blocks"];
|
|
19
|
+
export let parent: RenderBlockProps["parent"];
|
|
20
|
+
export let path: RenderBlockProps["path"];
|
|
21
|
+
|
|
22
|
+
let builderContext = getContext(BuilderContext.key);
|
|
23
|
+
|
|
24
|
+
function onClick() {
|
|
25
|
+
if (isEditing() && !blocks?.length) {
|
|
26
|
+
window.parent?.postMessage(
|
|
27
|
+
{
|
|
28
|
+
type: "builder.clickEmptyBlocks",
|
|
29
|
+
data: {
|
|
30
|
+
parentElementId: parent,
|
|
31
|
+
dataPath: path,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
"*"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function onMouseEnter() {
|
|
40
|
+
if (isEditing() && !blocks?.length) {
|
|
41
|
+
window.parent?.postMessage(
|
|
42
|
+
{
|
|
43
|
+
type: "builder.hoverEmptyBlocks",
|
|
44
|
+
data: {
|
|
45
|
+
parentElementId: parent,
|
|
46
|
+
dataPath: path,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
"*"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
$: className = () => {
|
|
54
|
+
return "builder-blocks" + (!blocks?.length ? " no-blocks" : "");
|
|
55
|
+
};
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
class={className() + " div"}
|
|
60
|
+
builder-path={path}
|
|
61
|
+
builder-parent-id={parent}
|
|
62
|
+
dataSet={{
|
|
63
|
+
class: className(),
|
|
64
|
+
}}
|
|
65
|
+
on:click={(event) => {
|
|
66
|
+
onClick();
|
|
67
|
+
}}
|
|
68
|
+
on:mouseenter={(event) => {
|
|
69
|
+
onMouseEnter();
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{#if blocks}
|
|
73
|
+
{#each blocks as block ("render-block-" + block.id)}
|
|
74
|
+
<RenderBlock {block} context={builderContext} />
|
|
75
|
+
{/each}
|
|
76
|
+
{/if}
|
|
77
|
+
|
|
78
|
+
{#if blocks}
|
|
79
|
+
{#each blocks as block ("block-style-" + block.id)}
|
|
80
|
+
<BlockStyles {block} context={builderContext} />
|
|
81
|
+
{/each}
|
|
82
|
+
{/if}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.div {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
align-items: stretch;
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import { getContext } from "svelte";
|
|
4
|
+
import BuilderContext from "../context/builder.context.js";
|
|
5
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
6
|
+
import "../types/builder-block.js";
|
|
7
|
+
import BlockStyles from "./render-block/block-styles.svelte";
|
|
8
|
+
import RenderBlock from "./render-block/render-block.svelte";
|
|
9
|
+
export let blocks;
|
|
10
|
+
export let parent;
|
|
11
|
+
export let path;
|
|
12
|
+
let builderContext = getContext(BuilderContext.key);
|
|
13
|
+
function onClick() {
|
|
14
|
+
if (isEditing() && !blocks?.length) {
|
|
15
|
+
window.parent?.postMessage({
|
|
16
|
+
type: "builder.clickEmptyBlocks",
|
|
17
|
+
data: {
|
|
18
|
+
parentElementId: parent,
|
|
19
|
+
dataPath: path,
|
|
20
|
+
},
|
|
21
|
+
}, "*");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function onMouseEnter() {
|
|
25
|
+
if (isEditing() && !blocks?.length) {
|
|
26
|
+
window.parent?.postMessage({
|
|
27
|
+
type: "builder.hoverEmptyBlocks",
|
|
28
|
+
data: {
|
|
29
|
+
parentElementId: parent,
|
|
30
|
+
dataPath: path,
|
|
31
|
+
},
|
|
32
|
+
}, "*");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
$: className = () => {
|
|
36
|
+
return "builder-blocks" + (!blocks?.length ? " no-blocks" : "");
|
|
37
|
+
};
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
class={className() + " div"}
|
|
42
|
+
builder-path={path}
|
|
43
|
+
builder-parent-id={parent}
|
|
44
|
+
dataSet={{
|
|
45
|
+
class: className(),
|
|
46
|
+
}}
|
|
47
|
+
on:click={(event) => {
|
|
48
|
+
onClick();
|
|
49
|
+
}}
|
|
50
|
+
on:mouseenter={(event) => {
|
|
51
|
+
onMouseEnter();
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{#if blocks}
|
|
55
|
+
{#each blocks as block ("render-block-" + block.id)}
|
|
56
|
+
<RenderBlock {block} context={builderContext} />
|
|
57
|
+
{/each}
|
|
58
|
+
{/if}
|
|
59
|
+
|
|
60
|
+
{#if blocks}
|
|
61
|
+
{#each blocks as block ("block-style-" + block.id)}
|
|
62
|
+
<BlockStyles {block} context={builderContext} />
|
|
63
|
+
{/each}
|
|
64
|
+
{/if}
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<style>
|
|
68
|
+
.div {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
align-items: stretch;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export declare type RenderBlockProps = {
|
|
3
|
+
blocks?: BuilderBlock[];
|
|
4
|
+
parent?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
};
|
|
7
|
+
import { BuilderBlock } from "../types/builder-block.js";
|
|
8
|
+
declare const __propDef: {
|
|
9
|
+
props: {
|
|
10
|
+
blocks: RenderBlockProps["blocks"];
|
|
11
|
+
parent: RenderBlockProps["parent"];
|
|
12
|
+
path: RenderBlockProps["path"];
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export declare type RenderBlocksProps = typeof __propDef.props;
|
|
20
|
+
export declare type RenderBlocksEvents = typeof __propDef.events;
|
|
21
|
+
export declare type RenderBlocksSlots = typeof __propDef.slots;
|
|
22
|
+
export default class RenderBlocks extends SvelteComponentTyped<RenderBlocksProps, RenderBlocksEvents, RenderBlocksSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
interface CustomFont {
|
|
3
|
+
family?: string;
|
|
4
|
+
kind?: string;
|
|
5
|
+
fileUrl?: string;
|
|
6
|
+
files?: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
cssCode?: string;
|
|
13
|
+
customFonts?: CustomFont[];
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import RenderInlinedStyles from "../../render-inlined-styles.svelte";
|
|
19
|
+
|
|
20
|
+
export let cssCode: Props["cssCode"];
|
|
21
|
+
export let customFonts: Props["customFonts"];
|
|
22
|
+
|
|
23
|
+
function getCssFromFont(font) {
|
|
24
|
+
// TODO: compute what font sizes are used and only load those.......
|
|
25
|
+
const family =
|
|
26
|
+
font.family +
|
|
27
|
+
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
28
|
+
const name = family.split(",")[0];
|
|
29
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
30
|
+
let str = "";
|
|
31
|
+
|
|
32
|
+
if (url && family && name) {
|
|
33
|
+
str += `
|
|
34
|
+
@font-face {
|
|
35
|
+
font-family: "${family}";
|
|
36
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
37
|
+
font-display: fallback;
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
}
|
|
40
|
+
`.trim();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (font.files) {
|
|
44
|
+
for (const weight in font.files) {
|
|
45
|
+
const isNumber = String(Number(weight)) === weight;
|
|
46
|
+
|
|
47
|
+
if (!isNumber) {
|
|
48
|
+
continue;
|
|
49
|
+
} // TODO: maybe limit number loaded
|
|
50
|
+
|
|
51
|
+
const weightUrl = font.files[weight];
|
|
52
|
+
|
|
53
|
+
if (weightUrl && weightUrl !== url) {
|
|
54
|
+
str += `
|
|
55
|
+
@font-face {
|
|
56
|
+
font-family: "${family}";
|
|
57
|
+
src: url('${weightUrl}') format('woff2');
|
|
58
|
+
font-display: fallback;
|
|
59
|
+
font-weight: ${weight};
|
|
60
|
+
}
|
|
61
|
+
`.trim();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return str;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getFontCss({ customFonts }) {
|
|
70
|
+
// TODO: flag for this
|
|
71
|
+
// if (!builder.allowCustomFonts) {
|
|
72
|
+
// return '';
|
|
73
|
+
// }
|
|
74
|
+
// TODO: separate internal data from external
|
|
75
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
76
|
+
}
|
|
77
|
+
$: injectedStyles = () => {
|
|
78
|
+
return `
|
|
79
|
+
${cssCode || ""}
|
|
80
|
+
${getFontCss({
|
|
81
|
+
customFonts: customFonts,
|
|
82
|
+
})}`;
|
|
83
|
+
};
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<RenderInlinedStyles styles={injectedStyles()} />
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import RenderInlinedStyles from "../../render-inlined-styles.svelte";
|
|
4
|
+
export let cssCode;
|
|
5
|
+
export let customFonts;
|
|
6
|
+
function getCssFromFont(font) {
|
|
7
|
+
// TODO: compute what font sizes are used and only load those.......
|
|
8
|
+
const family = font.family +
|
|
9
|
+
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
10
|
+
const name = family.split(",")[0];
|
|
11
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
12
|
+
let str = "";
|
|
13
|
+
if (url && family && name) {
|
|
14
|
+
str += `
|
|
15
|
+
@font-face {
|
|
16
|
+
font-family: "${family}";
|
|
17
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
18
|
+
font-display: fallback;
|
|
19
|
+
font-weight: 400;
|
|
20
|
+
}
|
|
21
|
+
`.trim();
|
|
22
|
+
}
|
|
23
|
+
if (font.files) {
|
|
24
|
+
for (const weight in font.files) {
|
|
25
|
+
const isNumber = String(Number(weight)) === weight;
|
|
26
|
+
if (!isNumber) {
|
|
27
|
+
continue;
|
|
28
|
+
} // TODO: maybe limit number loaded
|
|
29
|
+
const weightUrl = font.files[weight];
|
|
30
|
+
if (weightUrl && weightUrl !== url) {
|
|
31
|
+
str += `
|
|
32
|
+
@font-face {
|
|
33
|
+
font-family: "${family}";
|
|
34
|
+
src: url('${weightUrl}') format('woff2');
|
|
35
|
+
font-display: fallback;
|
|
36
|
+
font-weight: ${weight};
|
|
37
|
+
}
|
|
38
|
+
`.trim();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return str;
|
|
43
|
+
}
|
|
44
|
+
function getFontCss({ customFonts }) {
|
|
45
|
+
// TODO: flag for this
|
|
46
|
+
// if (!builder.allowCustomFonts) {
|
|
47
|
+
// return '';
|
|
48
|
+
// }
|
|
49
|
+
// TODO: separate internal data from external
|
|
50
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
51
|
+
}
|
|
52
|
+
$: injectedStyles = () => {
|
|
53
|
+
return `
|
|
54
|
+
${cssCode || ""}
|
|
55
|
+
${getFontCss({
|
|
56
|
+
customFonts: customFonts,
|
|
57
|
+
})}`;
|
|
58
|
+
};
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<RenderInlinedStyles styles={injectedStyles()} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
interface CustomFont {
|
|
3
|
+
family?: string;
|
|
4
|
+
kind?: string;
|
|
5
|
+
fileUrl?: string;
|
|
6
|
+
files?: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface Props {
|
|
11
|
+
cssCode?: string;
|
|
12
|
+
customFonts?: CustomFont[];
|
|
13
|
+
}
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
cssCode: Props["cssCode"];
|
|
17
|
+
customFonts: Props["customFonts"];
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
};
|
|
22
|
+
slots: {};
|
|
23
|
+
};
|
|
24
|
+
export declare type RenderStylesProps = typeof __propDef.props;
|
|
25
|
+
export declare type RenderStylesEvents = typeof __propDef.events;
|
|
26
|
+
export declare type RenderStylesSlots = typeof __propDef.slots;
|
|
27
|
+
export default class RenderStyles extends SvelteComponentTyped<RenderStylesProps, RenderStylesEvents, RenderStylesSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './render-content.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './render-content.svelte';
|
|
File without changes
|