@prismicio/svelte 2.2.3-pr.64.0df0234 → 2.2.3-pr.64.13cae0c
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 +12 -17
- package/dist/PrismicLink.svelte +2 -2
- package/dist/PrismicLink.svelte.d.ts +1 -1
- package/dist/PrismicRichText/DefaultComponent.svelte +1 -1
- package/dist/PrismicTable.svelte +2 -2
- package/dist/SliceZone/SliceZone.svelte +1 -6
- package/dist/kit/redirectToPreviewURL.d.ts +4 -4
- package/dist/kit/redirectToPreviewURL.js +4 -4
- package/package.json +1 -1
- package/src/PrismicImage.svelte +12 -17
- package/src/PrismicLink.svelte +2 -2
- package/src/PrismicRichText/DefaultComponent.svelte +1 -1
- package/src/PrismicTable.svelte +2 -2
- package/src/SliceZone/SliceZone.svelte +1 -6
- package/src/kit/redirectToPreviewURL.ts +4 -4
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 }
|
|
@@ -103,17 +106,9 @@
|
|
|
103
106
|
})
|
|
104
107
|
|
|
105
108
|
function castInt(input: string | number | null | undefined): number | null | undefined {
|
|
106
|
-
if (typeof input
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const parsed = Number.parseInt(input)
|
|
110
|
-
|
|
111
|
-
if (Number.isNaN(parsed)) {
|
|
112
|
-
return undefined
|
|
113
|
-
} else {
|
|
114
|
-
return parsed
|
|
115
|
-
}
|
|
116
|
-
}
|
|
109
|
+
if (typeof input !== "string") return input
|
|
110
|
+
const parsed = Number.parseInt(input)
|
|
111
|
+
return Number.isNaN(parsed) ? undefined : parsed
|
|
117
112
|
}
|
|
118
113
|
</script>
|
|
119
114
|
|
package/dist/PrismicLink.svelte
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
| {
|
|
27
27
|
href: HTMLAnchorAttributes["href"]
|
|
28
|
-
document
|
|
28
|
+
document?: never
|
|
29
29
|
field?: never
|
|
30
30
|
}
|
|
31
31
|
)
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
-->
|
|
54
54
|
|
|
55
55
|
<a {...linkAttrs} rel={resolvedRel} {href} {...restProps}>
|
|
56
|
-
{#if children}{@render children
|
|
56
|
+
{#if children}{@render children()}{:else}{field?.text}{/if}
|
|
57
57
|
</a>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
{#if as}
|
|
19
|
-
<svelte:element this={as} {...dirProp} {...attrs}
|
|
19
|
+
<svelte:element this={as} {...dirProp} {...attrs}>{@render children()}</svelte:element>
|
|
20
20
|
{:else if node.type === "heading1"}
|
|
21
21
|
<h1 {...dirProp} {...attrs}>{@render children()}</h1>
|
|
22
22
|
{:else if node.type === "heading2"}
|
package/dist/PrismicTable.svelte
CHANGED
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
<!-- This formatting is intentional to prevent unwanted whitespace between elements. -->
|
|
75
75
|
{#if isFilled.table(field)}
|
|
76
76
|
{#if typeof Table === "function"}<Table table={field}
|
|
77
|
-
>{#if field
|
|
77
|
+
>{#if field.head}{@render thead(field.head)}{/if}{@render tbody(field.body)}</Table
|
|
78
78
|
>{:else}<table {...Table}>
|
|
79
|
-
{#if field
|
|
79
|
+
{#if field.head}{@render thead(field.head)}{/if}{@render tbody(field.body)}
|
|
80
80
|
</table>{/if}
|
|
81
81
|
{:else if Fallback}
|
|
82
82
|
<Fallback />
|
|
@@ -38,12 +38,7 @@
|
|
|
38
38
|
defaultComponent?: Component<SliceComponentProps> | undefined
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const {
|
|
42
|
-
slices = [],
|
|
43
|
-
components = {},
|
|
44
|
-
context = {},
|
|
45
|
-
defaultComponent = undefined,
|
|
46
|
-
}: Props = $props()
|
|
41
|
+
const { slices = [], components = {}, context = {}, defaultComponent }: Props = $props()
|
|
47
42
|
</script>
|
|
48
43
|
|
|
49
44
|
<!--
|
|
@@ -27,14 +27,14 @@ export type RedirectToPreviewURLConfig = {
|
|
|
27
27
|
* Return the created `Response` in your `+server` file.
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
|
-
*
|
|
31
|
-
* import { createClient } from "
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createClient } from "#lib/prismicio.ts"
|
|
32
32
|
* import { redirectToPreviewURL } from "@prismicio/svelte/kit"
|
|
33
33
|
*
|
|
34
|
-
* export async function GET({ fetch, request }) {
|
|
34
|
+
* export async function GET({ fetch, request, cookies }) {
|
|
35
35
|
* const client = createClient({ fetch })
|
|
36
36
|
*
|
|
37
|
-
* return await redirectToPreviewURL({ client, request })
|
|
37
|
+
* return await redirectToPreviewURL({ client, request, cookies })
|
|
38
38
|
* }
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
@@ -6,14 +6,14 @@ import * as prismic from "@prismicio/client";
|
|
|
6
6
|
* Return the created `Response` in your `+server` file.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
*
|
|
10
|
-
* import { createClient } from "
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createClient } from "#lib/prismicio.ts"
|
|
11
11
|
* import { redirectToPreviewURL } from "@prismicio/svelte/kit"
|
|
12
12
|
*
|
|
13
|
-
* export async function GET({ fetch, request }) {
|
|
13
|
+
* export async function GET({ fetch, request, cookies }) {
|
|
14
14
|
* const client = createClient({ fetch })
|
|
15
15
|
*
|
|
16
|
-
* return await redirectToPreviewURL({ client, request })
|
|
16
|
+
* return await redirectToPreviewURL({ client, request, cookies })
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
package/package.json
CHANGED
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 }
|
|
@@ -103,17 +106,9 @@
|
|
|
103
106
|
})
|
|
104
107
|
|
|
105
108
|
function castInt(input: string | number | null | undefined): number | null | undefined {
|
|
106
|
-
if (typeof input
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const parsed = Number.parseInt(input)
|
|
110
|
-
|
|
111
|
-
if (Number.isNaN(parsed)) {
|
|
112
|
-
return undefined
|
|
113
|
-
} else {
|
|
114
|
-
return parsed
|
|
115
|
-
}
|
|
116
|
-
}
|
|
109
|
+
if (typeof input !== "string") return input
|
|
110
|
+
const parsed = Number.parseInt(input)
|
|
111
|
+
return Number.isNaN(parsed) ? undefined : parsed
|
|
117
112
|
}
|
|
118
113
|
</script>
|
|
119
114
|
|
package/src/PrismicLink.svelte
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
| {
|
|
27
27
|
href: HTMLAnchorAttributes["href"]
|
|
28
|
-
document
|
|
28
|
+
document?: never
|
|
29
29
|
field?: never
|
|
30
30
|
}
|
|
31
31
|
)
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
-->
|
|
54
54
|
|
|
55
55
|
<a {...linkAttrs} rel={resolvedRel} {href} {...restProps}>
|
|
56
|
-
{#if children}{@render children
|
|
56
|
+
{#if children}{@render children()}{:else}{field?.text}{/if}
|
|
57
57
|
</a>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
{#if as}
|
|
19
|
-
<svelte:element this={as} {...dirProp} {...attrs}
|
|
19
|
+
<svelte:element this={as} {...dirProp} {...attrs}>{@render children()}</svelte:element>
|
|
20
20
|
{:else if node.type === "heading1"}
|
|
21
21
|
<h1 {...dirProp} {...attrs}>{@render children()}</h1>
|
|
22
22
|
{:else if node.type === "heading2"}
|
package/src/PrismicTable.svelte
CHANGED
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
<!-- This formatting is intentional to prevent unwanted whitespace between elements. -->
|
|
75
75
|
{#if isFilled.table(field)}
|
|
76
76
|
{#if typeof Table === "function"}<Table table={field}
|
|
77
|
-
>{#if field
|
|
77
|
+
>{#if field.head}{@render thead(field.head)}{/if}{@render tbody(field.body)}</Table
|
|
78
78
|
>{:else}<table {...Table}>
|
|
79
|
-
{#if field
|
|
79
|
+
{#if field.head}{@render thead(field.head)}{/if}{@render tbody(field.body)}
|
|
80
80
|
</table>{/if}
|
|
81
81
|
{:else if Fallback}
|
|
82
82
|
<Fallback />
|
|
@@ -38,12 +38,7 @@
|
|
|
38
38
|
defaultComponent?: Component<SliceComponentProps> | undefined
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const {
|
|
42
|
-
slices = [],
|
|
43
|
-
components = {},
|
|
44
|
-
context = {},
|
|
45
|
-
defaultComponent = undefined,
|
|
46
|
-
}: Props = $props()
|
|
41
|
+
const { slices = [], components = {}, context = {}, defaultComponent }: Props = $props()
|
|
47
42
|
</script>
|
|
48
43
|
|
|
49
44
|
<!--
|
|
@@ -36,14 +36,14 @@ export type RedirectToPreviewURLConfig = {
|
|
|
36
36
|
* Return the created `Response` in your `+server` file.
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
|
-
*
|
|
40
|
-
* import { createClient } from "
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { createClient } from "#lib/prismicio.ts"
|
|
41
41
|
* import { redirectToPreviewURL } from "@prismicio/svelte/kit"
|
|
42
42
|
*
|
|
43
|
-
* export async function GET({ fetch, request }) {
|
|
43
|
+
* export async function GET({ fetch, request, cookies }) {
|
|
44
44
|
* const client = createClient({ fetch })
|
|
45
45
|
*
|
|
46
|
-
* return await redirectToPreviewURL({ client, request })
|
|
46
|
+
* return await redirectToPreviewURL({ client, request, cookies })
|
|
47
47
|
* }
|
|
48
48
|
* ```
|
|
49
49
|
*/
|