@builder.io/sdk-svelte 0.0.1-6 → 0.0.1-7
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/package.json +1 -1
- package/src/blocks/columns/columns.svelte +1 -1
- package/src/blocks/image/image.svelte +1 -1
- package/src/components/render-block/render-block.helpers.js +21 -0
- package/src/components/render-block/render-block.svelte +17 -6
- package/src/components/render-content/render-content.svelte +9 -7
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ export let builderBlock;
|
|
|
38
38
|
|
|
39
39
|
<picture >
|
|
40
40
|
|
|
41
|
-
<img loading="lazy" alt={altText}
|
|
41
|
+
<img loading="lazy" alt={altText} role={altText ? 'presentation' : undefined} style={{
|
|
42
42
|
objectPosition: backgroundSize || 'center',
|
|
43
43
|
objectFit: backgroundSize || 'cover'
|
|
44
44
|
}} class={'builder-image' + (className ? ' ' + className : '')} src={image} srcset={srcset} sizes={sizes} />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
2
|
+
"area",
|
|
3
|
+
"base",
|
|
4
|
+
"br",
|
|
5
|
+
"col",
|
|
6
|
+
"embed",
|
|
7
|
+
"hr",
|
|
8
|
+
"img",
|
|
9
|
+
"input",
|
|
10
|
+
"keygen",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
];
|
|
18
|
+
const isEmptyHtmlElement = (tagName) => EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
19
|
+
export {
|
|
20
|
+
isEmptyHtmlElement
|
|
21
|
+
};
|
|
@@ -12,6 +12,7 @@ import { getBlockStyles } from '../../functions/get-block-styles.js';
|
|
|
12
12
|
import { getBlockTag } from '../../functions/get-block-tag.js';
|
|
13
13
|
import { getProcessedBlock } from '../../functions/get-processed-block.js';
|
|
14
14
|
import BlockStyles, { } from './block-styles.svelte';
|
|
15
|
+
import { isEmptyHtmlElement } from './render-block.helpers.js';
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -103,9 +104,11 @@ return componentRef() ? [] : children();
|
|
|
103
104
|
</script>
|
|
104
105
|
|
|
105
106
|
|
|
107
|
+
{#if !componentInfo?.()?.noWrap }
|
|
108
|
+
|
|
106
109
|
|
|
107
110
|
|
|
108
|
-
{#if !
|
|
111
|
+
{#if !isEmptyHtmlElement(tagName()) }
|
|
109
112
|
|
|
110
113
|
|
|
111
114
|
<svelte:element {...propertiesAndActions()} style={css()} this={tagName()} >
|
|
@@ -128,7 +131,7 @@ return componentRef() ? [] : children();
|
|
|
128
131
|
|
|
129
132
|
|
|
130
133
|
{#each children() as child, index }
|
|
131
|
-
<svelte:self block={child} ></svelte:self>
|
|
134
|
+
<svelte:self key={child.id} block={child} ></svelte:self>
|
|
132
135
|
{/each}
|
|
133
136
|
|
|
134
137
|
|
|
@@ -140,7 +143,7 @@ return componentRef() ? [] : children();
|
|
|
140
143
|
|
|
141
144
|
|
|
142
145
|
{#each noCompRefChildren() as child, index }
|
|
143
|
-
<svelte:self block={child} ></svelte:self>
|
|
146
|
+
<svelte:self key={child.id} block={child} ></svelte:self>
|
|
144
147
|
{/each}
|
|
145
148
|
|
|
146
149
|
|
|
@@ -149,15 +152,23 @@ return componentRef() ? [] : children();
|
|
|
149
152
|
|
|
150
153
|
|
|
151
154
|
|
|
155
|
+
{:else}
|
|
156
|
+
<svelte:element {...propertiesAndActions()} style={css()} this={tagName()} ></svelte:element>
|
|
157
|
+
|
|
158
|
+
{/if}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
152
163
|
{:else}
|
|
153
164
|
<svelte:component {...componentOptions()} attributes={propertiesAndActions()} builderBlock={useBlock()} style={css()} this={componentRef()} >
|
|
154
|
-
|
|
165
|
+
|
|
155
166
|
|
|
156
167
|
{#each children() as child, index }
|
|
157
|
-
<svelte:self block={child} ></svelte:self>
|
|
168
|
+
<svelte:self key={child.id} block={child} ></svelte:self>
|
|
158
169
|
{/each}
|
|
159
170
|
|
|
160
171
|
|
|
161
|
-
|
|
172
|
+
</svelte:component>
|
|
162
173
|
|
|
163
174
|
{/if}
|
|
@@ -111,14 +111,16 @@ Object.entries(requests).forEach(([key, url]) => {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
function emitStateUpdate() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
if (isEditing()) {
|
|
115
|
+
window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
|
|
116
|
+
detail: {
|
|
117
|
+
state: contentState(),
|
|
118
|
+
ref: {
|
|
119
|
+
name: model
|
|
120
|
+
}
|
|
119
121
|
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
$: useContent = () => {
|
|
124
126
|
const mergedContent = { ...content,
|