@websline/cms-view-utils 1.0.0-alpha.3 → 1.0.0-alpha.5
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/dist/previewBridge.global.js +1 -1
- package/package.json +4 -1
- package/src/components/AddBlockPlaceholder.svelte +42 -33
- package/src/components/BlockWrapper.svelte +12 -12
- package/src/components/EditableBlock.svelte +5 -0
- package/src/components/PageContent.svelte +7 -0
- package/src/components/Picture.svelte +2 -2
- package/src/index.js +1 -0
- package/src/utils/notify.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={BLOCK_ADD:"BLOCK_ADD",BLOCK_DELETE:"BLOCK_DELETE",BLOCK_EDIT:"BLOCK_EDIT",BLOCK_SHOW:"BLOCK_SHOW",BLOCK_HIDE:"BLOCK_HIDE",SLUG_CHANGED:"SLUG_CHANGED",SLUG_ON_LOAD:"SLUG_ON_LOAD",IFRAME_DOM_LOADED:"IFRAME_DOM_LOADED",CURRENT_BLOCK_EDIT:"CURRENT_BLOCK_EDIT",SCROLL_TO_BLOCK:"SCROLL_TO_BLOCK"},_=(r,L={})=>{r&&window.parent!==window&&window.parent.postMessage({type:r,payload:L},"*")};(function(){if(window.parent===window||window.__PREVIEW_BRIDGE_INITIALIZED__)return;window.__PREVIEW_BRIDGE_INITIALIZED__=!0;let r=t=>t.metaKey||t.ctrlKey||t.shiftKey,L=t=>{let n=t.target.closest("a[href]");if(!n||n.target==="_blank"||r(t))return;let o=new URL(n.href,window.location.origin);o.origin===window.location.origin&&(t.preventDefault(),t.stopPropagation(),_(e.SLUG_CHANGED,{slug:o.pathname}))};document.addEventListener("click",L,!0),_(e.SLUG_ON_LOAD,{slug:window.location.pathname}),window.addEventListener("load",()=>{_(e.IFRAME_DOM_LOADED)});let
|
|
1
|
+
(()=>{var e={BLOCK_ADD:"BLOCK_ADD",BLOCK_DELETE:"BLOCK_DELETE",BLOCK_EDIT:"BLOCK_EDIT",BLOCK_POSITION:"BLOCK_POSITION",BLOCK_SHOW:"BLOCK_SHOW",BLOCK_HIDE:"BLOCK_HIDE",SLUG_CHANGED:"SLUG_CHANGED",SLUG_ON_LOAD:"SLUG_ON_LOAD",IFRAME_DOM_LOADED:"IFRAME_DOM_LOADED",CURRENT_BLOCK_EDIT:"CURRENT_BLOCK_EDIT",SCROLL_TO_BLOCK:"SCROLL_TO_BLOCK"},_=(r,L={})=>{r&&window.parent!==window&&window.parent.postMessage({type:r,payload:L},"*")};(function(){if(window.parent===window||window.__PREVIEW_BRIDGE_INITIALIZED__)return;window.__PREVIEW_BRIDGE_INITIALIZED__=!0;let r=t=>t.metaKey||t.ctrlKey||t.shiftKey,L=t=>{let n=t.target.closest("a[href]");if(!n||n.target==="_blank"||r(t))return;let o=new URL(n.href,window.location.origin);o.origin===window.location.origin&&(t.preventDefault(),t.stopPropagation(),_(e.SLUG_CHANGED,{slug:o.pathname}))};document.addEventListener("click",L,!0),_(e.SLUG_ON_LOAD,{slug:window.location.pathname}),window.addEventListener("load",()=>{_(e.IFRAME_DOM_LOADED)});let E=t=>{let n=`[data-cms-block-id="${t}"]`,o=0,i=10,O=setInterval(()=>{let a=document.querySelector(n);a&&(a.scrollIntoView({behavior:"smooth",block:"center"}),clearInterval(O)),++o>=i&&clearInterval(O)},100)};window.addEventListener("message",t=>{let{type:n,payload:o}=t.data||{};if(n&&n===e.SCROLL_TO_BLOCK){let{draftBlockUuid:i}=o||{};if(!i)return;E(i)}})})();})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websline/cms-view-utils",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"jsonwebtoken": "^9.0.3"
|
|
20
20
|
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsup": "^8.5.1"
|
|
23
|
+
},
|
|
21
24
|
"peerDependencies": {
|
|
22
25
|
"svelte": "^5.0.0"
|
|
23
26
|
},
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
let {
|
|
5
5
|
class: className,
|
|
6
|
-
color = "#
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
color = "#dadad8",
|
|
7
|
+
hoverColor = "#E7E5E1",
|
|
8
|
+
hoverBorderColor = "#D1CECA",
|
|
9
|
+
textColor = "#121110",
|
|
10
|
+
iconBackgroundColor = "#FFFFFF",
|
|
11
|
+
iconColor = "#121110",
|
|
12
|
+
label = "Hier das erste Element einfügen",
|
|
13
|
+
sublabel = "Füge über den Button einen neuen Block hinzu,um mit dem Bearbeiten der Page zu beginnen.",
|
|
14
|
+
sublabelColor = "#92908D",
|
|
9
15
|
} = $props();
|
|
10
16
|
|
|
11
17
|
const handleClick = () => {
|
|
@@ -13,37 +19,40 @@
|
|
|
13
19
|
};
|
|
14
20
|
</script>
|
|
15
21
|
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class="absolute inset-0 rounded-lg border-2 border-dashed transition-all duration-150 group-hover:opacity-60"
|
|
22
|
-
style="border-color: var(--block-color); opacity: 0.25;">
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
<div
|
|
26
|
-
class="absolute inset-0 rounded-lg transition-all duration-150 group-hover:opacity-10"
|
|
27
|
-
style="background: var(--block-color); opacity: 0;">
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
<div class="relative flex h-full w-full flex-col items-center justify-center gap-2">
|
|
22
|
+
<div>
|
|
23
|
+
<button
|
|
24
|
+
class={`group relative flex min-h-32 w-full cursor-pointer items-center justify-center rounded-lg transition-all duration-300 ${className}`}
|
|
25
|
+
style={`--block-color: ${color}; --block-hover-color: ${hoverColor}; --block-hover-border-color: ${hoverBorderColor}; --block-text: ${textColor}; --block-icon-background: ${iconBackgroundColor}; --block-icon-color: ${iconColor}; --sublabel-color: ${sublabelColor};`}
|
|
26
|
+
onclick={handleClick}>
|
|
31
27
|
<div
|
|
32
|
-
class="flex
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
class="relative mx-auto flex max-w-md flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-[var(--block-color)] px-6 py-8 text-center transition-colors duration-300 group-hover:border-[var(--block-hover-border-color)] group-hover:bg-[var(--block-hover-color)]">
|
|
29
|
+
<svg
|
|
30
|
+
width="24"
|
|
31
|
+
height="24"
|
|
32
|
+
viewBox="0 0 24 24"
|
|
33
|
+
fill="none"
|
|
34
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
35
|
+
<path
|
|
36
|
+
class="fill-[var(--block-icon-background)]"
|
|
37
|
+
d="M0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12Z"
|
|
38
|
+
fill="#FFFFFF" />
|
|
35
39
|
<path
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
stroke
|
|
39
|
-
stroke-
|
|
40
|
+
class="stroke-[var(--block-icon-color)]"
|
|
41
|
+
d="M12.0231 6.6665L12.0092 17.3332M6.66675 11.9998H17.3334"
|
|
42
|
+
stroke="#121110"
|
|
43
|
+
stroke-width="1.5"
|
|
44
|
+
stroke-linecap="round"
|
|
45
|
+
stroke-linejoin="round" />
|
|
40
46
|
</svg>
|
|
41
|
-
</div>
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
<span
|
|
49
|
+
class="text-sm text-[var(--block-text)] transition-opacity duration-300 group-hover:opacity-100">
|
|
50
|
+
{label}
|
|
51
|
+
</span>
|
|
52
|
+
<span
|
|
53
|
+
class="text-sm text-[var(--sublabel-color)] transition-opacity duration-300 group-hover:opacity-100">
|
|
54
|
+
{sublabel}
|
|
55
|
+
</span>
|
|
56
|
+
</div>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
const defaultSpacingValues = {
|
|
5
5
|
bottom: {
|
|
6
|
-
none: "
|
|
7
|
-
s: "
|
|
8
|
-
m: "
|
|
9
|
-
l: "
|
|
10
|
-
xl: "
|
|
6
|
+
none: "mb-0",
|
|
7
|
+
s: "mb-4",
|
|
8
|
+
m: "mb-12",
|
|
9
|
+
l: "mb-24",
|
|
10
|
+
xl: "mb-30",
|
|
11
11
|
},
|
|
12
12
|
top: {
|
|
13
|
-
none: "
|
|
14
|
-
s: "
|
|
15
|
-
m: "
|
|
16
|
-
l: "
|
|
17
|
-
xl: "
|
|
13
|
+
none: "mt-0",
|
|
14
|
+
s: "mt-4",
|
|
15
|
+
m: "mt-12",
|
|
16
|
+
l: "mt-24",
|
|
17
|
+
xl: "mt-30",
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
|
|
35
35
|
let spacingClass = $derived(
|
|
36
36
|
[
|
|
37
|
-
spacingMap.top[spacingTop] ?? spacingMap.top.
|
|
38
|
-
spacingMap.bottom[spacingBottom] ?? spacingMap.bottom.
|
|
37
|
+
spacingMap.top[spacingTop] ?? spacingMap.top.none,
|
|
38
|
+
spacingMap.bottom[spacingBottom] ?? spacingMap.bottom.none,
|
|
39
39
|
].join(" "),
|
|
40
40
|
);
|
|
41
41
|
|
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
draftBlockUuid: block.uuid,
|
|
53
53
|
});
|
|
54
54
|
break;
|
|
55
|
+
case CMS_ACTIONS.position:
|
|
56
|
+
notifyCMS(EVENTS.BLOCK_POSITION, {
|
|
57
|
+
draftBlockUuid: block.uuid,
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
55
60
|
case CMS_ACTIONS.showBlock:
|
|
56
61
|
notifyCMS(EVENTS.BLOCK_SHOW, {
|
|
57
62
|
draftBlockUuid: block.uuid,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
let {
|
|
3
|
-
className
|
|
3
|
+
class: className,
|
|
4
4
|
decoding = "async",
|
|
5
5
|
image,
|
|
6
6
|
loading = "lazy",
|
|
@@ -82,6 +82,6 @@
|
|
|
82
82
|
height={data.fallbackFormat.height}
|
|
83
83
|
{loading}
|
|
84
84
|
{decoding}
|
|
85
|
-
class={`h-full w-full object-cover ${className}`} />
|
|
85
|
+
class={`h-full w-full object-cover${className ? ` ${className}` : ""}`} />
|
|
86
86
|
</picture>
|
|
87
87
|
{/if}
|
package/src/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { isValid } from "./utils/blockValidation.js";
|
|
|
3
3
|
export { default as AddBlockPlaceholder } from "./components/AddBlockPlaceholder.svelte";
|
|
4
4
|
export { default as BlockWrapper } from "./components/BlockWrapper.svelte";
|
|
5
5
|
export { default as EditableBlock } from "./components/EditableBlock.svelte";
|
|
6
|
+
export { default as PageContent } from "./components/PageContent.svelte";
|
|
6
7
|
export { default as Picture } from "./components/Picture.svelte";
|