@prismicio/svelte 2.2.3-pr.64.d803be5 → 2.2.3-pr.66.8d23348
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/PrismicImage.svelte +9 -6
- package/dist/PrismicLink.svelte +1 -1
- package/dist/PrismicLink.svelte.d.ts +1 -1
- package/dist/PrismicTable.svelte +6 -1
- package/dist/SliceSimulator.svelte +5 -7
- package/dist/SliceSimulator.svelte.d.ts +31 -9
- package/dist/index.d.ts +5 -1
- package/dist/kit/PrismicPreview.svelte +6 -3
- package/dist/kit/redirectToPreviewURL.d.ts +3 -3
- package/dist/kit/redirectToPreviewURL.js +1 -1
- package/package.json +9 -9
- package/src/PrismicImage.svelte +9 -6
- package/src/PrismicLink.svelte +1 -1
- package/src/PrismicTable.svelte +6 -1
- package/src/SliceSimulator.svelte +5 -7
- package/src/index.ts +8 -1
- package/src/kit/PrismicPreview.svelte +6 -3
- package/src/kit/redirectToPreviewURL.ts +3 -3
package/dist/PrismicImage.svelte
CHANGED
|
@@ -75,12 +75,15 @@
|
|
|
75
75
|
|
|
76
76
|
const ar = field.dimensions.width / field.dimensions.height
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const castedWidth = castInt(width)
|
|
79
|
+
const castedHeight = castInt(height)
|
|
80
|
+
|
|
81
|
+
let resolvedWidth = castedWidth ?? field.dimensions.width
|
|
82
|
+
let resolvedHeight = castedHeight ?? field.dimensions.height
|
|
83
|
+
if (castedWidth != null && castedHeight == null) {
|
|
84
|
+
resolvedHeight = castedWidth / ar
|
|
85
|
+
} else if (castedWidth == null && castedHeight != null) {
|
|
86
|
+
resolvedWidth = castedHeight * ar
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
return { resolvedWidth, resolvedHeight }
|
package/dist/PrismicLink.svelte
CHANGED
package/dist/PrismicTable.svelte
CHANGED
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
|
|
31
31
|
const { field, components = {}, fallback: Fallback }: Props = $props()
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const Table = components.table
|
|
34
|
+
const Thead = components.thead
|
|
35
|
+
const Tbody = components.tbody
|
|
36
|
+
const Tr = components.tr
|
|
37
|
+
const Th = components.th
|
|
38
|
+
const Td = components.td
|
|
34
39
|
</script>
|
|
35
40
|
|
|
36
41
|
{#snippet thead(head: TableFieldHead)}
|
|
@@ -10,23 +10,19 @@
|
|
|
10
10
|
simulatorClass,
|
|
11
11
|
simulatorRootClass,
|
|
12
12
|
} from "@prismicio/simulator/kit"
|
|
13
|
-
import type { Snippet } from "svelte"
|
|
14
|
-
import type { ClassValue } from "svelte/elements"
|
|
15
13
|
|
|
16
14
|
const defaultProps = getDefaultProps()
|
|
17
15
|
|
|
18
16
|
type Props = {
|
|
19
17
|
zIndex?: number
|
|
20
18
|
background?: string
|
|
21
|
-
class?:
|
|
22
|
-
children?: Snippet<[{ slices: ReturnType<typeof getDefaultSlices> }]>
|
|
19
|
+
class?: string
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
const {
|
|
26
23
|
zIndex = defaultProps.zIndex,
|
|
27
24
|
background = defaultProps.background,
|
|
28
25
|
class: className,
|
|
29
|
-
children,
|
|
30
26
|
}: Props = $props()
|
|
31
27
|
|
|
32
28
|
let slices = $state.raw(getDefaultSlices())
|
|
@@ -55,7 +51,7 @@
|
|
|
55
51
|
</script>
|
|
56
52
|
|
|
57
53
|
<div
|
|
58
|
-
class={
|
|
54
|
+
class="{simulatorClass} {className}"
|
|
59
55
|
style="z-index: {zIndex}; position: fixed; top: 0; left: 0; width: 100%; height: 100vh; overflow: auto; background: {background}"
|
|
60
56
|
>
|
|
61
57
|
{#if message}
|
|
@@ -72,7 +68,9 @@
|
|
|
72
68
|
onsubmit={disableEventHandler}
|
|
73
69
|
onkeypress={disableEventHandler}
|
|
74
70
|
>
|
|
75
|
-
|
|
71
|
+
<!-- TODO: Use a snippet in the next major; it would break `let:slices`. -->
|
|
72
|
+
<!-- svelte-ignore slot_element_deprecated -->
|
|
73
|
+
<slot {slices} />
|
|
76
74
|
</div>
|
|
77
75
|
{/if}
|
|
78
76
|
</div>
|
|
@@ -1,14 +1,36 @@
|
|
|
1
|
-
import { getDefaultSlices } from "@prismicio/simulator/kit";
|
|
2
|
-
import type { Snippet } from "svelte";
|
|
3
|
-
import type { ClassValue } from "svelte/elements";
|
|
4
1
|
type Props = {
|
|
5
2
|
zIndex?: number;
|
|
6
3
|
background?: string;
|
|
7
|
-
class?:
|
|
8
|
-
children?: Snippet<[{
|
|
9
|
-
slices: ReturnType<typeof getDefaultSlices>;
|
|
10
|
-
}]>;
|
|
4
|
+
class?: string;
|
|
11
5
|
};
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: Props & {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
20
|
+
default: any;
|
|
21
|
+
} ? Props extends Record<string, never> ? any : {
|
|
22
|
+
children?: any;
|
|
23
|
+
} : {});
|
|
24
|
+
declare const SliceSimulator: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<Props, {
|
|
25
|
+
default: {
|
|
26
|
+
slices: import("@prismicio/client").SliceZone;
|
|
27
|
+
};
|
|
28
|
+
}>, {
|
|
29
|
+
[evt: string]: CustomEvent<any>;
|
|
30
|
+
}, {
|
|
31
|
+
default: {
|
|
32
|
+
slices: import("@prismicio/client").SliceZone;
|
|
33
|
+
};
|
|
34
|
+
}, {}, "">;
|
|
35
|
+
type SliceSimulator = InstanceType<typeof SliceSimulator>;
|
|
14
36
|
export default SliceSimulator;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RichTextComponents } from "./types";
|
|
1
2
|
export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
|
|
2
3
|
export { default as PrismicImage } from "./PrismicImage.svelte";
|
|
3
4
|
export { default as PrismicLink } from "./PrismicLink.svelte";
|
|
@@ -6,4 +7,7 @@ export { default as PrismicTable } from "./PrismicTable.svelte";
|
|
|
6
7
|
export { default as PrismicText } from "./PrismicText.svelte";
|
|
7
8
|
export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
|
|
8
9
|
export { default as SliceSimulator } from "./SliceSimulator.svelte";
|
|
9
|
-
|
|
10
|
+
/** @deprecated Replaced with `RichTextComponents` */
|
|
11
|
+
export type SvelteRichTextSerializer = RichTextComponents;
|
|
12
|
+
export type { RichTextComponents };
|
|
13
|
+
export type { RichTextComponentProps, SliceComponentProps } from "./types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { beforeNavigate, goto,
|
|
2
|
+
import { beforeNavigate, goto, invalidateAll } from "$app/navigation"
|
|
3
3
|
import { getToolbarSrc } from "@prismicio/client"
|
|
4
4
|
import { onMount } from "svelte"
|
|
5
5
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prismicPreviewUpdate",
|
|
37
37
|
(event) => {
|
|
38
38
|
event.preventDefault()
|
|
39
|
-
|
|
39
|
+
invalidateAll()
|
|
40
40
|
},
|
|
41
41
|
{ signal: controller.signal },
|
|
42
42
|
)
|
|
@@ -55,7 +55,10 @@
|
|
|
55
55
|
),
|
|
56
56
|
window.location.origin,
|
|
57
57
|
),
|
|
58
|
-
{
|
|
58
|
+
{
|
|
59
|
+
invalidateAll: true,
|
|
60
|
+
noScroll: true,
|
|
61
|
+
},
|
|
59
62
|
)
|
|
60
63
|
},
|
|
61
64
|
{ signal: controller.signal },
|
|
@@ -6,13 +6,13 @@ export type RedirectToPreviewURLConfig = {
|
|
|
6
6
|
/**
|
|
7
7
|
* The `request` object from a `+server` file.
|
|
8
8
|
*
|
|
9
|
-
* @see SvelteKit `+server` docs: \<https://svelte.dev/docs/
|
|
9
|
+
* @see SvelteKit `+server` docs: \<https://kit.svelte.dev/docs/routing#server\>
|
|
10
10
|
*/
|
|
11
11
|
request: Request;
|
|
12
12
|
/**
|
|
13
13
|
* The `cookies` object from a `+server` file.
|
|
14
14
|
*
|
|
15
|
-
* @see SvelteKit `+server` docs: \<https://svelte.dev/docs/
|
|
15
|
+
* @see SvelteKit `+server` docs: \<https://kit.svelte.dev/docs/routing#server\>
|
|
16
16
|
*/
|
|
17
17
|
cookies: Cookies;
|
|
18
18
|
/** The default redirect URL if a URL cannot be determined for the previewed document. */
|
|
@@ -27,7 +27,7 @@ export type RedirectToPreviewURLConfig = {
|
|
|
27
27
|
* Return the created `Response` in your `+server` file.
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
|
-
*
|
|
30
|
+
* ```typescript
|
|
31
31
|
* import { createClient } from "$lib/prismicio.js"
|
|
32
32
|
* import { redirectToPreviewURL } from "@prismicio/svelte/kit"
|
|
33
33
|
*
|
|
@@ -6,7 +6,7 @@ import * as prismic from "@prismicio/client";
|
|
|
6
6
|
* Return the created `Response` in your `+server` file.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
*
|
|
9
|
+
* ```typescript
|
|
10
10
|
* import { createClient } from "$lib/prismicio.js"
|
|
11
11
|
* import { redirectToPreviewURL } from "@prismicio/svelte/kit"
|
|
12
12
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/svelte",
|
|
3
|
-
"version": "2.2.3-pr.
|
|
3
|
+
"version": "2.2.3-pr.66.8d23348",
|
|
4
4
|
"description": "Svelte components to present Prismic content.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismic",
|
|
@@ -64,25 +64,25 @@
|
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@prismicio/client": "^7.22.3",
|
|
66
66
|
"@prismicio/mock": "^0.7.2",
|
|
67
|
-
"@sveltejs/kit": "^
|
|
67
|
+
"@sveltejs/kit": "^2.70.3",
|
|
68
68
|
"@sveltejs/package": "^3.0.0",
|
|
69
69
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
70
70
|
"@testing-library/svelte": "^5.4.2",
|
|
71
71
|
"@types/node": "^26.6.5",
|
|
72
|
-
"@vitest/coverage-v8": "^5.0.
|
|
72
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
73
73
|
"globals": "^17.13.0",
|
|
74
|
-
"happy-dom": "^
|
|
75
|
-
"oxfmt": "^0.
|
|
76
|
-
"oxlint": "^1.
|
|
74
|
+
"happy-dom": "^20.14.6",
|
|
75
|
+
"oxfmt": "^0.72.0",
|
|
76
|
+
"oxlint": "^1.87.0",
|
|
77
77
|
"standard-version": "^9.5.0",
|
|
78
78
|
"svelte": "^5.57.2",
|
|
79
79
|
"typescript": "^6.0.3",
|
|
80
|
-
"vitest": "^5.0.
|
|
80
|
+
"vitest": "^5.0.3"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@prismicio/client": ">=7",
|
|
84
|
-
"@sveltejs/kit": "^
|
|
85
|
-
"svelte": "^5
|
|
84
|
+
"@sveltejs/kit": "^2",
|
|
85
|
+
"svelte": "^5"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|
|
88
88
|
"@sveltejs/kit": {
|
package/src/PrismicImage.svelte
CHANGED
|
@@ -75,12 +75,15 @@
|
|
|
75
75
|
|
|
76
76
|
const ar = field.dimensions.width / field.dimensions.height
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const castedWidth = castInt(width)
|
|
79
|
+
const castedHeight = castInt(height)
|
|
80
|
+
|
|
81
|
+
let resolvedWidth = castedWidth ?? field.dimensions.width
|
|
82
|
+
let resolvedHeight = castedHeight ?? field.dimensions.height
|
|
83
|
+
if (castedWidth != null && castedHeight == null) {
|
|
84
|
+
resolvedHeight = castedWidth / ar
|
|
85
|
+
} else if (castedWidth == null && castedHeight != null) {
|
|
86
|
+
resolvedWidth = castedHeight * ar
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
return { resolvedWidth, resolvedHeight }
|
package/src/PrismicLink.svelte
CHANGED
package/src/PrismicTable.svelte
CHANGED
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
|
|
31
31
|
const { field, components = {}, fallback: Fallback }: Props = $props()
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const Table = components.table
|
|
34
|
+
const Thead = components.thead
|
|
35
|
+
const Tbody = components.tbody
|
|
36
|
+
const Tr = components.tr
|
|
37
|
+
const Th = components.th
|
|
38
|
+
const Td = components.td
|
|
34
39
|
</script>
|
|
35
40
|
|
|
36
41
|
{#snippet thead(head: TableFieldHead)}
|
|
@@ -10,23 +10,19 @@
|
|
|
10
10
|
simulatorClass,
|
|
11
11
|
simulatorRootClass,
|
|
12
12
|
} from "@prismicio/simulator/kit"
|
|
13
|
-
import type { Snippet } from "svelte"
|
|
14
|
-
import type { ClassValue } from "svelte/elements"
|
|
15
13
|
|
|
16
14
|
const defaultProps = getDefaultProps()
|
|
17
15
|
|
|
18
16
|
type Props = {
|
|
19
17
|
zIndex?: number
|
|
20
18
|
background?: string
|
|
21
|
-
class?:
|
|
22
|
-
children?: Snippet<[{ slices: ReturnType<typeof getDefaultSlices> }]>
|
|
19
|
+
class?: string
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
const {
|
|
26
23
|
zIndex = defaultProps.zIndex,
|
|
27
24
|
background = defaultProps.background,
|
|
28
25
|
class: className,
|
|
29
|
-
children,
|
|
30
26
|
}: Props = $props()
|
|
31
27
|
|
|
32
28
|
let slices = $state.raw(getDefaultSlices())
|
|
@@ -55,7 +51,7 @@
|
|
|
55
51
|
</script>
|
|
56
52
|
|
|
57
53
|
<div
|
|
58
|
-
class={
|
|
54
|
+
class="{simulatorClass} {className}"
|
|
59
55
|
style="z-index: {zIndex}; position: fixed; top: 0; left: 0; width: 100%; height: 100vh; overflow: auto; background: {background}"
|
|
60
56
|
>
|
|
61
57
|
{#if message}
|
|
@@ -72,7 +68,9 @@
|
|
|
72
68
|
onsubmit={disableEventHandler}
|
|
73
69
|
onkeypress={disableEventHandler}
|
|
74
70
|
>
|
|
75
|
-
|
|
71
|
+
<!-- TODO: Use a snippet in the next major; it would break `let:slices`. -->
|
|
72
|
+
<!-- svelte-ignore slot_element_deprecated -->
|
|
73
|
+
<slot {slices} />
|
|
76
74
|
</div>
|
|
77
75
|
{/if}
|
|
78
76
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RichTextComponents } from "./types"
|
|
2
|
+
|
|
1
3
|
export { default as PrismicEmbed } from "./PrismicEmbed.svelte"
|
|
2
4
|
export { default as PrismicImage } from "./PrismicImage.svelte"
|
|
3
5
|
export { default as PrismicLink } from "./PrismicLink.svelte"
|
|
@@ -7,4 +9,9 @@ export { default as PrismicText } from "./PrismicText.svelte"
|
|
|
7
9
|
export { default as SliceZone } from "./SliceZone/SliceZone.svelte"
|
|
8
10
|
export { default as SliceSimulator } from "./SliceSimulator.svelte"
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
/** @deprecated Replaced with `RichTextComponents` */
|
|
13
|
+
// TODO: Remove in v3.
|
|
14
|
+
export type SvelteRichTextSerializer = RichTextComponents
|
|
15
|
+
export type { RichTextComponents }
|
|
16
|
+
|
|
17
|
+
export type { RichTextComponentProps, SliceComponentProps } from "./types"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { beforeNavigate, goto,
|
|
2
|
+
import { beforeNavigate, goto, invalidateAll } from "$app/navigation"
|
|
3
3
|
import { getToolbarSrc } from "@prismicio/client"
|
|
4
4
|
import { onMount } from "svelte"
|
|
5
5
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prismicPreviewUpdate",
|
|
37
37
|
(event) => {
|
|
38
38
|
event.preventDefault()
|
|
39
|
-
|
|
39
|
+
invalidateAll()
|
|
40
40
|
},
|
|
41
41
|
{ signal: controller.signal },
|
|
42
42
|
)
|
|
@@ -55,7 +55,10 @@
|
|
|
55
55
|
),
|
|
56
56
|
window.location.origin,
|
|
57
57
|
),
|
|
58
|
-
{
|
|
58
|
+
{
|
|
59
|
+
invalidateAll: true,
|
|
60
|
+
noScroll: true,
|
|
61
|
+
},
|
|
59
62
|
)
|
|
60
63
|
},
|
|
61
64
|
{ signal: controller.signal },
|
|
@@ -11,14 +11,14 @@ export type RedirectToPreviewURLConfig = {
|
|
|
11
11
|
/**
|
|
12
12
|
* The `request` object from a `+server` file.
|
|
13
13
|
*
|
|
14
|
-
* @see SvelteKit `+server` docs: \<https://svelte.dev/docs/
|
|
14
|
+
* @see SvelteKit `+server` docs: \<https://kit.svelte.dev/docs/routing#server\>
|
|
15
15
|
*/
|
|
16
16
|
request: Request
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The `cookies` object from a `+server` file.
|
|
20
20
|
*
|
|
21
|
-
* @see SvelteKit `+server` docs: \<https://svelte.dev/docs/
|
|
21
|
+
* @see SvelteKit `+server` docs: \<https://kit.svelte.dev/docs/routing#server\>
|
|
22
22
|
*/
|
|
23
23
|
cookies: Cookies
|
|
24
24
|
|
|
@@ -36,7 +36,7 @@ export type RedirectToPreviewURLConfig = {
|
|
|
36
36
|
* Return the created `Response` in your `+server` file.
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
|
-
*
|
|
39
|
+
* ```typescript
|
|
40
40
|
* import { createClient } from "$lib/prismicio.js"
|
|
41
41
|
* import { redirectToPreviewURL } from "@prismicio/svelte/kit"
|
|
42
42
|
*
|