@prismicio/vue 5.3.0-canary.4c3e4ab → 5.3.0-canary.553482e
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.vue.d.cts +10 -23
- package/dist/PrismicImage.vue.d.cts.map +1 -1
- package/dist/PrismicLink.vue.d.cts +11 -26
- package/dist/PrismicLink.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts +6 -10
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/types.d.cts +25 -26
- package/dist/PrismicRichText/types.d.cts.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue.d.cts +2 -6
- package/dist/PrismicTable/PrismicTable.vue.d.cts.map +1 -1
- package/dist/PrismicTable/types.d.cts +7 -8
- package/dist/PrismicTable/types.d.cts.map +1 -1
- package/dist/PrismicText.vue.d.cts +4 -8
- package/dist/PrismicText.vue.d.cts.map +1 -1
- package/dist/SliceZone/SliceZone.vue.d.cts +5 -11
- package/dist/SliceZone/SliceZone.vue.d.cts.map +1 -1
- package/dist/SliceZone/types.d.cts +3 -9
- package/dist/SliceZone/types.d.cts.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/src/PrismicImage.cjs.map +1 -1
- package/dist/src/PrismicImage.js.map +1 -1
- package/dist/src/PrismicImage.vue.d.ts +10 -23
- package/dist/src/PrismicImage.vue.d.ts.map +1 -1
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicLink.cjs.map +1 -1
- package/dist/src/PrismicLink.js.map +1 -1
- package/dist/src/PrismicLink.vue.d.ts +11 -26
- package/dist/src/PrismicLink.vue.d.ts.map +1 -1
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs +3 -9
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js +3 -9
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts +2 -6
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs +2 -4
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js +2 -4
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs +10 -4
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js +11 -5
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/types.d.ts +25 -26
- package/dist/src/PrismicRichText/types.d.ts.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts +4 -8
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs +8 -8
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs +12 -30
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.js +12 -30
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.js.map +1 -1
- package/dist/src/PrismicTable/types.d.ts +7 -8
- package/dist/src/PrismicTable/types.d.ts.map +1 -1
- package/dist/src/PrismicText.cjs.map +1 -1
- package/dist/src/PrismicText.js.map +1 -1
- package/dist/src/PrismicText.vue.d.ts +4 -8
- package/dist/src/PrismicText.vue.d.ts.map +1 -1
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/SliceZone/SliceZone.cjs.map +1 -1
- package/dist/src/SliceZone/SliceZone.js.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue.d.ts +5 -11
- package/dist/src/SliceZone/SliceZone.vue.d.ts.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/SliceZone/types.d.ts +3 -9
- package/dist/src/SliceZone/types.d.ts.map +1 -1
- package/dist/src/lib/isInternalURL.cjs +2 -6
- package/dist/src/lib/isInternalURL.cjs.map +1 -1
- package/dist/src/lib/isInternalURL.js +2 -6
- package/dist/src/lib/isInternalURL.js.map +1 -1
- package/dist/src/types.cjs.map +1 -1
- package/dist/src/types.d.ts +11 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/types.d.cts +11 -1
- package/dist/types.d.cts.map +1 -1
- package/package.json +1 -3
- package/src/PrismicImage.vue +2 -6
- package/src/PrismicLink.vue +6 -18
- package/src/PrismicRichText/PrismicRichText.vue +13 -15
- package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +8 -4
- package/src/PrismicRichText/PrismicRichTextSerialize.vue +4 -3
- package/src/PrismicRichText/types.ts +57 -29
- package/src/PrismicTable/PrismicTable.vue +14 -18
- package/src/PrismicTable/PrismicTableDefaultComponents.ts +14 -39
- package/src/PrismicTable/types.ts +41 -23
- package/src/PrismicText.vue +2 -6
- package/src/SliceZone/SliceZone.vue +3 -9
- package/src/SliceZone/types.ts +3 -9
- package/src/lib/isInternalURL.ts +2 -6
- package/src/types.ts +13 -1
package/dist/src/types.d.ts
CHANGED
|
@@ -3,6 +3,16 @@ import { ConcreteComponent, DefineComponent, FunctionalComponent, Raw, defineAsy
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
type ComponentOrTagName = string | ConcreteComponent | Raw<DefineComponent>;
|
|
5
5
|
type VueComponent<TProps> = DefineComponent<{}, {}, any> | ReturnType<typeof defineAsyncComponent> | DefineComponent<TProps> | FunctionalComponent<TProps>;
|
|
6
|
+
/**
|
|
7
|
+
* A shorthand definition for `<PrismicRichText />` and `<PrismicTable />`
|
|
8
|
+
* component types.
|
|
9
|
+
*/
|
|
10
|
+
type VueComponentShorthand = {
|
|
11
|
+
/** The HTML element type rendered for this node type. */
|
|
12
|
+
as?: string;
|
|
13
|
+
/** Other attributes to apply to the element type. */
|
|
14
|
+
[Attribute: string]: string | boolean | null | undefined;
|
|
15
|
+
};
|
|
6
16
|
//#endregion
|
|
7
|
-
export { ComponentOrTagName, VueComponent };
|
|
17
|
+
export { ComponentOrTagName, VueComponent, VueComponentShorthand };
|
|
8
18
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;KAQY,kBAAA,YAET,oBACA,IAAI;KAEK,uBAGT,+BAEA,kBAAkB,wBAClB,gBAAgB,UAChB,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;KAQY,kBAAA,YAET,oBACA,IAAI;KAEK,uBAGT,+BAEA,kBAAkB,wBAClB,gBAAgB,UAChB,oBAAoB;AAZvB;;;;AAGM,KAeM,qBAAA,GAfN;EAEM;EAGT,EAAA,CAAA,EAAA,MAAA;EAEkB;EAAlB,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,OAAA,GAAA,IAAA,GAAA,SAAA;CACgB"}
|
package/dist/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tRaw,\n\tdefineAsyncComponent,\n} from \"vue\"\n\nexport type ComponentOrTagName =\n\t| string\n\t| ConcreteComponent\n\t| Raw<DefineComponent>\n\nexport type VueComponent<TProps> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-explicit-any\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\n\t| DefineComponent<TProps>\n\t| FunctionalComponent<TProps>\n\nexport const isVueComponent = <T>(\n\tcomponent: VueComponent<T> |
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tRaw,\n\tdefineAsyncComponent,\n} from \"vue\"\n\nexport type ComponentOrTagName =\n\t| string\n\t| ConcreteComponent\n\t| Raw<DefineComponent>\n\nexport type VueComponent<TProps> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-explicit-any\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\n\t| DefineComponent<TProps>\n\t| FunctionalComponent<TProps>\n\n/**\n * A shorthand definition for `<PrismicRichText />` and `<PrismicTable />`\n * component types.\n */\nexport type VueComponentShorthand = {\n\t/** The HTML element type rendered for this node type. */\n\tas?: string\n\n\t/** Other attributes to apply to the element type. */\n\t[Attribute: string]: string | boolean | null | undefined\n}\n\nexport const isVueComponent = <T>(\n\tcomponent: VueComponent<T> | VueComponentShorthand | undefined,\n): component is VueComponent<T> => {\n\treturn (\n\t\t!!component &&\n\t\t(typeof component === \"function\" ||\n\t\t\t(typeof component === \"object\" &&\n\t\t\t\t((\"render\" in component && typeof component.render === \"function\") ||\n\t\t\t\t\t(\"setup\" in component && typeof component.setup === \"function\") ||\n\t\t\t\t\t(\"__file\" in component && !!component.__file) ||\n\t\t\t\t\t(\"__name\" in component && !!component.__name) ||\n\t\t\t\t\t(\"props\" in component && typeof component.props === \"object\"))))\n\t)\n}\n"],"mappings":";AAkCA,MAAa,kBACZ,cACkC;AAClC,QACC,CAAC,CAAC,cACD,OAAO,cAAc,cACpB,OAAO,cAAc,aACnB,YAAY,aAAa,OAAO,UAAU,WAAW,cACrD,WAAW,aAAa,OAAO,UAAU,UAAU,cACnD,YAAY,aAAa,CAAC,CAAC,UAAU,UACrC,YAAY,aAAa,CAAC,CAAC,UAAU,UACrC,WAAW,aAAa,OAAO,UAAU,UAAU"}
|
package/dist/types.d.cts
CHANGED
|
@@ -3,6 +3,16 @@ import { ConcreteComponent, DefineComponent, FunctionalComponent, Raw, defineAsy
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
type ComponentOrTagName = string | ConcreteComponent | Raw<DefineComponent>;
|
|
5
5
|
type VueComponent<TProps> = DefineComponent<{}, {}, any> | ReturnType<typeof defineAsyncComponent> | DefineComponent<TProps> | FunctionalComponent<TProps>;
|
|
6
|
+
/**
|
|
7
|
+
* A shorthand definition for `<PrismicRichText />` and `<PrismicTable />`
|
|
8
|
+
* component types.
|
|
9
|
+
*/
|
|
10
|
+
type VueComponentShorthand = {
|
|
11
|
+
/** The HTML element type rendered for this node type. */
|
|
12
|
+
as?: string;
|
|
13
|
+
/** Other attributes to apply to the element type. */
|
|
14
|
+
[Attribute: string]: string | boolean | null | undefined;
|
|
15
|
+
};
|
|
6
16
|
//#endregion
|
|
7
|
-
export { ComponentOrTagName, VueComponent };
|
|
17
|
+
export { ComponentOrTagName, VueComponent, VueComponentShorthand };
|
|
8
18
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;KAQY,kBAAA,YAET,oBACA,IAAI;KAEK,uBAGT,+BAEA,kBAAkB,wBAClB,gBAAgB,UAChB,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;KAQY,kBAAA,YAET,oBACA,IAAI;KAEK,uBAGT,+BAEA,kBAAkB,wBAClB,gBAAgB,UAChB,oBAAoB;AAZvB;;;;AAGM,KAeM,qBAAA,GAfN;EAEM;EAGT,EAAA,CAAA,EAAA,MAAA;EAEkB;EAAlB,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,OAAA,GAAA,IAAA,GAAA,SAAA;CACgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/vue",
|
|
3
|
-
"version": "5.3.0-canary.
|
|
3
|
+
"version": "5.3.0-canary.553482e",
|
|
4
4
|
"description": "Vue plugin, components, and composables to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -34,8 +34,6 @@
|
|
|
34
34
|
"build": "tsdown",
|
|
35
35
|
"dev": "tsdown --watch",
|
|
36
36
|
"format": "prettier --write .",
|
|
37
|
-
"playground:build": "vite build playground",
|
|
38
|
-
"playground:dev": "vite playground",
|
|
39
37
|
"prepare": "npm run build",
|
|
40
38
|
"lint": "oxlint --deny-warnings",
|
|
41
39
|
"types": "vue-tsc --noEmit",
|
package/src/PrismicImage.vue
CHANGED
|
@@ -10,13 +10,9 @@ import { computed, watchEffect } from "vue"
|
|
|
10
10
|
|
|
11
11
|
import { devMsg } from "./lib/devMsg"
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Props for `<PrismicImage />`.
|
|
15
|
-
*/
|
|
13
|
+
/** Props for `<PrismicImage />`. */
|
|
16
14
|
export type PrismicImageProps = {
|
|
17
|
-
/**
|
|
18
|
-
* The Prismic image field or thumbnail to render.
|
|
19
|
-
*/
|
|
15
|
+
/** The Prismic image field or thumbnail to render. */
|
|
20
16
|
field: ImageField | ImageField<string>
|
|
21
17
|
|
|
22
18
|
/**
|
package/src/PrismicLink.vue
CHANGED
|
@@ -12,24 +12,16 @@ import { isInternalURL } from "./lib/isInternalURL"
|
|
|
12
12
|
|
|
13
13
|
import type { ComponentOrTagName } from "./types"
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* The default component rendered for internal URLs.
|
|
17
|
-
*/
|
|
15
|
+
/** The default component rendered for internal URLs. */
|
|
18
16
|
const defaultInternalComponent = "router-link"
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* The default component rendered for external URLs.
|
|
22
|
-
*/
|
|
18
|
+
/** The default component rendered for external URLs. */
|
|
23
19
|
const defaultExternalComponent = "a"
|
|
24
20
|
|
|
25
|
-
/**
|
|
26
|
-
* The default rel attribute rendered for external URLs.
|
|
27
|
-
*/
|
|
21
|
+
/** The default rel attribute rendered for external URLs. */
|
|
28
22
|
const defaultExternalRelAttribute = "noreferrer"
|
|
29
23
|
|
|
30
|
-
/**
|
|
31
|
-
* Props for `<PrismicLink />`.
|
|
32
|
-
*/
|
|
24
|
+
/** Props for `<PrismicLink />`. */
|
|
33
25
|
export type PrismicLinkProps = {
|
|
34
26
|
/**
|
|
35
27
|
* The link resolver used to resolve links.
|
|
@@ -67,16 +59,12 @@ export type PrismicLinkProps = {
|
|
|
67
59
|
externalComponent?: ComponentOrTagName
|
|
68
60
|
} & (
|
|
69
61
|
| {
|
|
70
|
-
/**
|
|
71
|
-
* The Prismic link field to render.
|
|
72
|
-
*/
|
|
62
|
+
/** The Prismic link field to render. */
|
|
73
63
|
field: LinkField
|
|
74
64
|
document?: never
|
|
75
65
|
}
|
|
76
66
|
| {
|
|
77
|
-
/**
|
|
78
|
-
* The Prismic document to render as a link.
|
|
79
|
-
*/
|
|
67
|
+
/** The Prismic document to render as a link. */
|
|
80
68
|
document: PrismicDocument
|
|
81
69
|
field?: never
|
|
82
70
|
}
|
|
@@ -8,23 +8,20 @@ import { asTree } from "@prismicio/client/richtext"
|
|
|
8
8
|
import type { PropType } from "vue"
|
|
9
9
|
import { computed } from "vue"
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import type { ComponentOrTagName, VueComponentShorthand } from "../types"
|
|
12
|
+
import { isVueComponent } from "../types"
|
|
12
13
|
import type {
|
|
13
|
-
|
|
14
|
+
InternalVueRichTextComponents,
|
|
15
|
+
VueRichTextComponent,
|
|
14
16
|
VueRichTextSerializer,
|
|
15
|
-
VueShorthand,
|
|
16
17
|
} from "./types"
|
|
17
18
|
|
|
18
19
|
import PrismicRichTextDefaultComponent from "./PrismicRichTextDefaultComponent.vue"
|
|
19
20
|
import PrismicRichTextSerialize from "./PrismicRichTextSerialize.vue"
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
-
* Props for `<PrismicRichText />`.
|
|
23
|
-
*/
|
|
22
|
+
/** Props for `<PrismicRichText />`. */
|
|
24
23
|
export type PrismicRichTextProps = {
|
|
25
|
-
/**
|
|
26
|
-
* The Prismic rich text field to render.
|
|
27
|
-
*/
|
|
24
|
+
/** The Prismic rich text field to render. */
|
|
28
25
|
field: RichTextField | null | undefined
|
|
29
26
|
|
|
30
27
|
/**
|
|
@@ -86,7 +83,10 @@ const children = computed(() => {
|
|
|
86
83
|
})
|
|
87
84
|
|
|
88
85
|
function getInternalComponent(type: keyof typeof RichTextNodeType) {
|
|
89
|
-
const maybeComponentOrShorthand = props.components?.[type]
|
|
86
|
+
const maybeComponentOrShorthand = props.components?.[type] as
|
|
87
|
+
| VueRichTextComponent
|
|
88
|
+
| VueComponentShorthand
|
|
89
|
+
| undefined
|
|
90
90
|
|
|
91
91
|
if (isVueComponent(maybeComponentOrShorthand)) {
|
|
92
92
|
return { is: maybeComponentOrShorthand }
|
|
@@ -94,14 +94,12 @@ function getInternalComponent(type: keyof typeof RichTextNodeType) {
|
|
|
94
94
|
|
|
95
95
|
return {
|
|
96
96
|
is: PrismicRichTextDefaultComponent,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
shorthand: maybeComponentOrShorthand as VueShorthand,
|
|
100
|
-
},
|
|
97
|
+
linkResolver: props.linkResolver,
|
|
98
|
+
shorthand: maybeComponentOrShorthand,
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
const internalComponents = computed<
|
|
102
|
+
const internalComponents = computed<InternalVueRichTextComponents>(() => {
|
|
105
103
|
return {
|
|
106
104
|
heading1: getInternalComponent("heading1"),
|
|
107
105
|
heading2: getInternalComponent("heading2"),
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import type { LinkResolverFunction } from "@prismicio/client"
|
|
3
3
|
import { computed } from "vue"
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { VueComponentShorthand } from "../types"
|
|
6
|
+
import type { RichTextComponentProps } from "./types"
|
|
6
7
|
|
|
7
8
|
import PrismicImage from "../PrismicImage.vue"
|
|
8
9
|
import PrismicLink from "../PrismicLink.vue"
|
|
@@ -10,13 +11,16 @@ import PrismicLink from "../PrismicLink.vue"
|
|
|
10
11
|
const props = defineProps<
|
|
11
12
|
RichTextComponentProps & {
|
|
12
13
|
linkResolver?: LinkResolverFunction
|
|
13
|
-
shorthand?:
|
|
14
|
+
shorthand?: VueComponentShorthand
|
|
14
15
|
}
|
|
15
16
|
>()
|
|
16
17
|
defineOptions({ name: "PrismicRichTextDefaultComponent" })
|
|
17
18
|
|
|
18
19
|
const as = computed(() => {
|
|
19
|
-
return props.node.type !== "image" &&
|
|
20
|
+
return props.node.type !== "image" &&
|
|
21
|
+
props.node.type !== "hyperlink" &&
|
|
22
|
+
props.node.type !== "label" &&
|
|
23
|
+
props.node.type !== "span"
|
|
20
24
|
? props.shorthand?.as
|
|
21
25
|
: undefined
|
|
22
26
|
})
|
|
@@ -74,7 +78,7 @@ const dir = computed(() => {
|
|
|
74
78
|
</ol>
|
|
75
79
|
<p class="block-img" v-else-if="node.type === 'image'">
|
|
76
80
|
<PrismicLink v-if="node.linkTo" :field="node.linkTo"
|
|
77
|
-
><PrismicImage :field="node"
|
|
81
|
+
><PrismicImage :field="node" v-bind="attrs"
|
|
78
82
|
/></PrismicLink>
|
|
79
83
|
<PrismicImage v-else :field="node" v-bind="attrs" />
|
|
80
84
|
</p>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { asTree } from "@prismicio/client/richtext"
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { InternalVueRichTextComponents } from "./types"
|
|
5
5
|
|
|
6
6
|
type PrismicRichTextSerializeProps = {
|
|
7
7
|
children: ReturnType<typeof asTree>["children"]
|
|
8
|
-
internalComponents:
|
|
8
|
+
internalComponents: InternalVueRichTextComponents
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const props = defineProps<PrismicRichTextSerializeProps>()
|
|
@@ -18,7 +18,8 @@ defineOptions({ name: "PrismicRichTextSerialize" })
|
|
|
18
18
|
:key="JSON.stringify(child)"
|
|
19
19
|
:is="internalComponents[child.type].is"
|
|
20
20
|
:node="child.node"
|
|
21
|
-
|
|
21
|
+
:link-resolver="internalComponents[child.type].linkResolver"
|
|
22
|
+
:shorthand="internalComponents[child.type].shorthand"
|
|
22
23
|
><PrismicRichTextSerialize
|
|
23
24
|
v-if="child.children.length"
|
|
24
25
|
:children="child.children"
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
LinkResolverFunction,
|
|
3
3
|
RTAnyNode,
|
|
4
|
-
|
|
4
|
+
RTEmNode,
|
|
5
|
+
RTEmbedNode,
|
|
6
|
+
RTHeading1Node,
|
|
7
|
+
RTHeading2Node,
|
|
8
|
+
RTHeading3Node,
|
|
9
|
+
RTHeading4Node,
|
|
10
|
+
RTHeading5Node,
|
|
11
|
+
RTHeading6Node,
|
|
12
|
+
RTImageNode,
|
|
13
|
+
RTLabelNode,
|
|
14
|
+
RTLinkNode,
|
|
15
|
+
RTListItemNode,
|
|
16
|
+
RTListNode,
|
|
17
|
+
RTOListItemNode,
|
|
18
|
+
RTOListNode,
|
|
19
|
+
RTParagraphNode,
|
|
20
|
+
RTPreformattedNode,
|
|
21
|
+
RTSpanNode,
|
|
22
|
+
RTStrongNode,
|
|
23
|
+
RichTextNodeTypes,
|
|
5
24
|
} from "@prismicio/client"
|
|
6
25
|
|
|
7
|
-
import type { VueComponent } from "../types"
|
|
26
|
+
import type { VueComponent, VueComponentShorthand } from "../types"
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
29
|
* A map of Rich Text block types to Vue Components. It is used to render Rich
|
|
@@ -12,13 +31,37 @@ import type { VueComponent } from "../types"
|
|
|
12
31
|
*
|
|
13
32
|
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/rich-text}
|
|
14
33
|
*/
|
|
15
|
-
export type VueRichTextSerializer =
|
|
16
|
-
|
|
17
|
-
>
|
|
34
|
+
export type VueRichTextSerializer = {
|
|
35
|
+
heading1?: RichTextComponentProps<RTHeading1Node> | VueComponentShorthand
|
|
36
|
+
heading2?: RichTextComponentProps<RTHeading2Node> | VueComponentShorthand
|
|
37
|
+
heading3?: RichTextComponentProps<RTHeading3Node> | VueComponentShorthand
|
|
38
|
+
heading4?: RichTextComponentProps<RTHeading4Node> | VueComponentShorthand
|
|
39
|
+
heading5?: RichTextComponentProps<RTHeading5Node> | VueComponentShorthand
|
|
40
|
+
heading6?: RichTextComponentProps<RTHeading6Node> | VueComponentShorthand
|
|
41
|
+
paragraph?: RichTextComponentProps<RTParagraphNode> | VueComponentShorthand
|
|
42
|
+
preformatted?:
|
|
43
|
+
| RichTextComponentProps<RTPreformattedNode>
|
|
44
|
+
| VueComponentShorthand
|
|
45
|
+
strong?: RichTextComponentProps<RTStrongNode> | VueComponentShorthand
|
|
46
|
+
em?: RichTextComponentProps<RTEmNode> | VueComponentShorthand
|
|
47
|
+
listItem?: RichTextComponentProps<RTListItemNode> | VueComponentShorthand
|
|
48
|
+
oListItem?: RichTextComponentProps<RTOListItemNode> | VueComponentShorthand
|
|
49
|
+
list?: RichTextComponentProps<RTListNode> | VueComponentShorthand
|
|
50
|
+
oList?: RichTextComponentProps<RTOListNode> | VueComponentShorthand
|
|
51
|
+
image?:
|
|
52
|
+
| RichTextComponentProps<RTImageNode>
|
|
53
|
+
| Omit<VueComponentShorthand, "as">
|
|
54
|
+
embed?: RichTextComponentProps<RTEmbedNode> | VueComponentShorthand
|
|
55
|
+
hyperlink?:
|
|
56
|
+
| RichTextComponentProps<RTLinkNode>
|
|
57
|
+
| Omit<VueComponentShorthand, "as">
|
|
58
|
+
label?:
|
|
59
|
+
| RichTextComponentProps<RTLabelNode>
|
|
60
|
+
| Omit<VueComponentShorthand, "as">
|
|
61
|
+
span?: RichTextComponentProps<RTSpanNode>
|
|
62
|
+
}
|
|
18
63
|
|
|
19
|
-
/**
|
|
20
|
-
* Props for a component rendering nodes from a Prismic rich text field.
|
|
21
|
-
*/
|
|
64
|
+
/** Props for a component rendering nodes from a Prismic rich text field. */
|
|
22
65
|
export type RichTextComponentProps<TRTNode extends RTAnyNode = RTAnyNode> = {
|
|
23
66
|
node: TRTNode
|
|
24
67
|
}
|
|
@@ -28,29 +71,14 @@ export type RichTextComponentProps<TRTNode extends RTAnyNode = RTAnyNode> = {
|
|
|
28
71
|
*
|
|
29
72
|
* @typeParam TRTNode - The type of rich text node(s) this component handles
|
|
30
73
|
*/
|
|
31
|
-
type VueRichTextComponent<TRTNode extends RTAnyNode = RTAnyNode> =
|
|
32
|
-
RichTextComponentProps<TRTNode
|
|
33
|
-
>
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A shorthand definition for {@link VueRichTextSerializer} component types.
|
|
37
|
-
*/
|
|
38
|
-
export type VueShorthand = {
|
|
39
|
-
/**
|
|
40
|
-
* The HTML element type rendered for this node type.
|
|
41
|
-
*/
|
|
42
|
-
as?: string
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Other attributes to apply to the element type.
|
|
46
|
-
*/
|
|
47
|
-
[Attribute: string]: string | boolean | null | undefined
|
|
48
|
-
}
|
|
74
|
+
export type VueRichTextComponent<TRTNode extends RTAnyNode = RTAnyNode> =
|
|
75
|
+
VueComponent<RichTextComponentProps<TRTNode>>
|
|
49
76
|
|
|
50
|
-
export type
|
|
51
|
-
|
|
77
|
+
export type InternalVueRichTextComponents = Record<
|
|
78
|
+
RichTextNodeTypes,
|
|
52
79
|
{
|
|
53
80
|
is: VueRichTextComponent
|
|
54
|
-
|
|
81
|
+
linkResolver?: LinkResolverFunction
|
|
82
|
+
shorthand?: VueComponentShorthand
|
|
55
83
|
}
|
|
56
84
|
>
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { type TableField, isFilled } from "@prismicio/client"
|
|
3
3
|
import { computed } from "vue"
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
5
|
+
import type { ComponentOrTagName, VueComponentShorthand } from "../types"
|
|
6
|
+
import { isVueComponent } from "../types"
|
|
7
7
|
import type { InternalVueTableComponents, VueTableComponents } from "./types"
|
|
8
8
|
|
|
9
9
|
import type { VueRichTextSerializer } from "../PrismicRichText"
|
|
@@ -11,13 +11,9 @@ import type { VueRichTextSerializer } from "../PrismicRichText"
|
|
|
11
11
|
import { defaultTableComponents } from "./PrismicTableDefaultComponents"
|
|
12
12
|
import PrismicTableRow from "./PrismicTableRow.vue"
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Props for `<PrismicTable />`.
|
|
16
|
-
*/
|
|
14
|
+
/** Props for `<PrismicTable />`. */
|
|
17
15
|
export type PrismicTableProps = {
|
|
18
|
-
/**
|
|
19
|
-
* The Prismic table field to render.
|
|
20
|
-
*/
|
|
16
|
+
/** The Prismic table field to render. */
|
|
21
17
|
field: TableField | undefined
|
|
22
18
|
|
|
23
19
|
/**
|
|
@@ -55,11 +51,11 @@ function getInternalComponent(type: keyof VueTableComponents) {
|
|
|
55
51
|
|
|
56
52
|
return {
|
|
57
53
|
is: defaultTableComponents[type],
|
|
58
|
-
shorthand: maybeComponentOrShorthand as
|
|
54
|
+
shorthand: maybeComponentOrShorthand as VueComponentShorthand,
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
const
|
|
58
|
+
const internalTableComponents = computed<InternalVueTableComponents>(() => {
|
|
63
59
|
return {
|
|
64
60
|
table: getInternalComponent("table"),
|
|
65
61
|
thead: getInternalComponent("thead"),
|
|
@@ -74,34 +70,34 @@ const tableComponents = computed<InternalVueTableComponents>(() => {
|
|
|
74
70
|
<template>
|
|
75
71
|
<component
|
|
76
72
|
v-if="isFilled.table(field)"
|
|
77
|
-
:is="
|
|
73
|
+
:is="internalTableComponents.table.is"
|
|
78
74
|
:table="field"
|
|
79
|
-
v-bind="{ ...$attrs, ...
|
|
75
|
+
v-bind="{ ...$attrs, ...internalTableComponents.table.shorthand }"
|
|
80
76
|
>
|
|
81
77
|
<component
|
|
82
78
|
v-if="field.head"
|
|
83
|
-
:is="
|
|
79
|
+
:is="internalTableComponents.thead.is"
|
|
84
80
|
:head="field.head"
|
|
85
|
-
v-bind="
|
|
81
|
+
v-bind="internalTableComponents.thead.shorthand"
|
|
86
82
|
>
|
|
87
83
|
<PrismicTableRow
|
|
88
84
|
v-for="row in field.head.rows"
|
|
89
85
|
:key="row.key"
|
|
90
86
|
:row="row"
|
|
91
|
-
:internalTableComponents="
|
|
87
|
+
:internalTableComponents="internalTableComponents"
|
|
92
88
|
:components="components"
|
|
93
89
|
/>
|
|
94
90
|
</component>
|
|
95
91
|
<component
|
|
96
|
-
:is="
|
|
92
|
+
:is="internalTableComponents.tbody.is"
|
|
97
93
|
:body="field.body"
|
|
98
|
-
v-bind="
|
|
94
|
+
v-bind="internalTableComponents.tbody.shorthand"
|
|
99
95
|
>
|
|
100
96
|
<PrismicTableRow
|
|
101
97
|
v-for="row in field.body.rows"
|
|
102
98
|
:key="row.key"
|
|
103
99
|
:row="row"
|
|
104
|
-
:internalTableComponents="
|
|
100
|
+
:internalTableComponents="internalTableComponents"
|
|
105
101
|
:components="components"
|
|
106
102
|
/>
|
|
107
103
|
</component>
|
|
@@ -1,69 +1,44 @@
|
|
|
1
1
|
import { defineComponent, h } from "vue"
|
|
2
|
-
import type { PropType } from "vue"
|
|
3
2
|
|
|
4
|
-
import type {
|
|
3
|
+
import type { VueTableComponents } from "./types"
|
|
5
4
|
|
|
6
5
|
import * as getTableComponentProps from "./getTableComponentProps"
|
|
7
6
|
|
|
8
|
-
export const defaultTableComponents:
|
|
7
|
+
export const defaultTableComponents: Required<VueTableComponents> = {
|
|
9
8
|
table: defineComponent({
|
|
10
|
-
props:
|
|
11
|
-
...getTableComponentProps.table(),
|
|
12
|
-
as: { type: String as PropType<string | undefined> },
|
|
13
|
-
},
|
|
9
|
+
props: getTableComponentProps.table(),
|
|
14
10
|
setup(props, { attrs, slots }) {
|
|
15
|
-
return () =>
|
|
16
|
-
h(props.as ?? "table", attrs, slots.default ? slots.default() : [])
|
|
11
|
+
return () => h("table", attrs, slots.default ? slots.default() : [])
|
|
17
12
|
},
|
|
18
13
|
}),
|
|
19
14
|
thead: defineComponent({
|
|
20
|
-
props:
|
|
21
|
-
...getTableComponentProps.thead(),
|
|
22
|
-
as: { type: String as PropType<string | undefined> },
|
|
23
|
-
},
|
|
15
|
+
props: getTableComponentProps.thead(),
|
|
24
16
|
setup(props, { attrs, slots }) {
|
|
25
|
-
return () =>
|
|
26
|
-
h(props.as ?? "thead", attrs, slots.default ? slots.default() : [])
|
|
17
|
+
return () => h("thead", attrs, slots.default ? slots.default() : [])
|
|
27
18
|
},
|
|
28
19
|
}),
|
|
29
20
|
tbody: defineComponent({
|
|
30
|
-
props:
|
|
31
|
-
...getTableComponentProps.tbody(),
|
|
32
|
-
as: { type: String as PropType<string | undefined> },
|
|
33
|
-
},
|
|
21
|
+
props: getTableComponentProps.tbody(),
|
|
34
22
|
setup(props, { attrs, slots }) {
|
|
35
|
-
return () =>
|
|
36
|
-
h(props.as ?? "tbody", attrs, slots.default ? slots.default() : [])
|
|
23
|
+
return () => h("tbody", attrs, slots.default ? slots.default() : [])
|
|
37
24
|
},
|
|
38
25
|
}),
|
|
39
26
|
tr: defineComponent({
|
|
40
|
-
props:
|
|
41
|
-
...getTableComponentProps.tr(),
|
|
42
|
-
as: { type: String as PropType<string | undefined> },
|
|
43
|
-
},
|
|
27
|
+
props: getTableComponentProps.tr(),
|
|
44
28
|
setup(props, { attrs, slots }) {
|
|
45
|
-
return () =>
|
|
46
|
-
h(props.as ?? "tr", attrs, slots.default ? slots.default() : [])
|
|
29
|
+
return () => h("tr", attrs, slots.default ? slots.default() : [])
|
|
47
30
|
},
|
|
48
31
|
}),
|
|
49
32
|
th: defineComponent({
|
|
50
|
-
props:
|
|
51
|
-
...getTableComponentProps.th(),
|
|
52
|
-
as: { type: String as PropType<string | undefined> },
|
|
53
|
-
},
|
|
33
|
+
props: getTableComponentProps.th(),
|
|
54
34
|
setup(props, { attrs, slots }) {
|
|
55
|
-
return () =>
|
|
56
|
-
h(props.as ?? "th", attrs, slots.default ? slots.default() : [])
|
|
35
|
+
return () => h("th", attrs, slots.default ? slots.default() : [])
|
|
57
36
|
},
|
|
58
37
|
}),
|
|
59
38
|
td: defineComponent({
|
|
60
|
-
props:
|
|
61
|
-
...getTableComponentProps.td(),
|
|
62
|
-
as: { type: String as PropType<string | undefined> },
|
|
63
|
-
},
|
|
39
|
+
props: getTableComponentProps.td(),
|
|
64
40
|
setup(props, { attrs, slots }) {
|
|
65
|
-
return () =>
|
|
66
|
-
h(props.as ?? "td", attrs, slots.default ? slots.default() : [])
|
|
41
|
+
return () => h("td", attrs, slots.default ? slots.default() : [])
|
|
67
42
|
},
|
|
68
43
|
}),
|
|
69
44
|
}
|
|
@@ -8,8 +8,7 @@ import type {
|
|
|
8
8
|
TableFieldHeaderCell,
|
|
9
9
|
} from "@prismicio/client"
|
|
10
10
|
|
|
11
|
-
import type {
|
|
12
|
-
import type { VueComponent } from "../types"
|
|
11
|
+
import type { VueComponent, VueComponentShorthand } from "../types"
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* A map of Table block types to Vue Components. It is used to render table
|
|
@@ -18,30 +17,49 @@ import type { VueComponent } from "../types"
|
|
|
18
17
|
* @see Templating Table fields from Prismic {@link https://prismic.io/docs/table}
|
|
19
18
|
*/
|
|
20
19
|
export type VueTableComponents = {
|
|
21
|
-
table?:
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
table?:
|
|
21
|
+
| VueComponent<{ table: TableField<"filled"> }>
|
|
22
|
+
| Omit<VueComponentShorthand, "as">
|
|
23
|
+
thead?:
|
|
24
|
+
| VueComponent<{ head: TableFieldHead }>
|
|
25
|
+
| Omit<VueComponentShorthand, "as">
|
|
26
|
+
tbody?:
|
|
27
|
+
| VueComponent<{ body: TableFieldBody }>
|
|
28
|
+
| Omit<VueComponentShorthand, "as">
|
|
24
29
|
tr?:
|
|
25
30
|
| VueComponent<{ row: TableFieldBodyRow | TableFieldHeadRow }>
|
|
26
|
-
|
|
|
27
|
-
th?:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
thead: VueComponent<{ head: TableFieldHead; as?: string }>
|
|
34
|
-
tbody: VueComponent<{ body: TableFieldBody; as?: string }>
|
|
35
|
-
tr: VueComponent<{ row: TableFieldBodyRow | TableFieldHeadRow; as?: string }>
|
|
36
|
-
th: VueComponent<{ cell: TableFieldHeaderCell; as?: string }>
|
|
37
|
-
td: VueComponent<{ cell: TableFieldDataCell; as?: string }>
|
|
31
|
+
| Omit<VueComponentShorthand, "as">
|
|
32
|
+
th?:
|
|
33
|
+
| VueComponent<{ cell: TableFieldHeaderCell }>
|
|
34
|
+
| Omit<VueComponentShorthand, "as">
|
|
35
|
+
td?:
|
|
36
|
+
| VueComponent<{ cell: TableFieldDataCell }>
|
|
37
|
+
| Omit<VueComponentShorthand, "as">
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export type InternalVueTableComponents = {
|
|
41
|
-
table: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
table: {
|
|
42
|
+
is: VueTableComponents["table"]
|
|
43
|
+
shorthand?: Omit<VueComponentShorthand, "as">
|
|
44
|
+
}
|
|
45
|
+
thead: {
|
|
46
|
+
is: VueTableComponents["thead"]
|
|
47
|
+
shorthand?: Omit<VueComponentShorthand, "as">
|
|
48
|
+
}
|
|
49
|
+
tbody: {
|
|
50
|
+
is: VueTableComponents["tbody"]
|
|
51
|
+
shorthand?: Omit<VueComponentShorthand, "as">
|
|
52
|
+
}
|
|
53
|
+
tr: {
|
|
54
|
+
is: VueTableComponents["tr"]
|
|
55
|
+
shorthand?: Omit<VueComponentShorthand, "as">
|
|
56
|
+
}
|
|
57
|
+
th: {
|
|
58
|
+
is: VueTableComponents["th"]
|
|
59
|
+
shorthand?: Omit<VueComponentShorthand, "as">
|
|
60
|
+
}
|
|
61
|
+
td: {
|
|
62
|
+
is: VueTableComponents["td"]
|
|
63
|
+
shorthand?: Omit<VueComponentShorthand, "as">
|
|
64
|
+
}
|
|
47
65
|
}
|
package/src/PrismicText.vue
CHANGED
|
@@ -6,13 +6,9 @@ import { watchEffect } from "vue"
|
|
|
6
6
|
|
|
7
7
|
import { devMsg } from "./lib/devMsg"
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Props for `<PrismicText />`.
|
|
11
|
-
*/
|
|
9
|
+
/** Props for `<PrismicText />`. */
|
|
12
10
|
export type PrismicTextProps = {
|
|
13
|
-
/**
|
|
14
|
-
* The Prismic rich text field to render.
|
|
15
|
-
*/
|
|
11
|
+
/** The Prismic rich text field to render. */
|
|
16
12
|
field: RichTextField | null | undefined
|
|
17
13
|
|
|
18
14
|
/**
|