@prismicio/vue 5.3.0-pr.88.72388e2 → 5.3.0-pr.89.d0f4ac2
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 +13 -19
- package/dist/PrismicImage.vue.d.cts.map +1 -1
- package/dist/PrismicLink.vue.d.cts +1 -4
- package/dist/PrismicLink.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts +5 -6
- 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 +5 -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 +1 -3
- package/dist/PrismicText.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/createPrismic.d.cts +61 -0
- package/dist/createPrismic.d.cts.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -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 +17 -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 +5 -8
- package/dist/src/PrismicLink.vue.d.ts.map +1 -1
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs +6 -10
- 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 +6 -10
- 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 +9 -10
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs +11 -5
- 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 +11 -5
- 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/index.d.ts +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 +5 -6
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs +17 -9
- 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 +17 -9
- 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/PrismicTableRow.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicTable/index.d.ts +1 -0
- 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 +3 -5
- 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.vue.d.ts +2 -2
- package/dist/src/SliceZone/types.d.ts +3 -9
- package/dist/src/SliceZone/types.d.ts.map +1 -1
- package/dist/src/createPrismic.cjs +33 -0
- package/dist/src/createPrismic.cjs.map +1 -0
- package/dist/src/createPrismic.d.ts +63 -0
- package/dist/src/createPrismic.d.ts.map +1 -0
- package/dist/src/createPrismic.js +32 -0
- package/dist/src/createPrismic.js.map +1 -0
- 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 +5 -8
- package/src/PrismicLink.vue +14 -14
- package/src/PrismicRichText/PrismicRichText.vue +24 -15
- package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +8 -4
- package/src/PrismicRichText/PrismicRichTextSerialize.vue +4 -3
- package/src/PrismicRichText/index.ts +1 -1
- package/src/PrismicRichText/types.ts +57 -29
- package/src/PrismicTable/PrismicTable.vue +27 -19
- package/src/PrismicTable/PrismicTableDefaultComponents.ts +14 -39
- package/src/PrismicTable/PrismicTableRow.vue +2 -2
- package/src/PrismicTable/index.ts +2 -0
- package/src/PrismicTable/types.ts +41 -23
- package/src/PrismicText.vue +1 -3
- package/src/SliceZone/types.ts +3 -9
- package/src/createPrismic.ts +86 -0
- package/src/index.ts +5 -1
- package/src/lib/isInternalURL.ts +2 -6
- package/src/types.ts +13 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/SliceZone/types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAKY;;;KAOP,gBAA4D,CAAA,eAA5B,SAA4B,CAAA,GAAf,MAAe,SAAA,eAAA,GAC9D,MAD8D,CAAA,YAAA,CAAA,GAE9D,MAF8D,SAE/C,gBAF+C,GAG7D,MAH6D,CAAA,MAAA,CAAA,GAAA,KAAA;;;;;;AAYjE;AACO,KADK,eACL,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAD2D,IAC3D,CAAN,KAAM,CAAA,UAAA,CAAA,EAAA,IAAA,GAAA,YAAA,CAAA;;;;AAUP;AAaA;;AACG,KAdS,gBAcT,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EACiB,IAAA,EAdb,KAca,CAdP,UAcO,CAAA,CAAA,YAAA,CAAA;CAAjB;;AAoBH;;;;;AAWA;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/SliceZone/types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAKY;;;KAOP,gBAA4D,CAAA,eAA5B,SAA4B,CAAA,GAAf,MAAe,SAAA,eAAA,GAC9D,MAD8D,CAAA,YAAA,CAAA,GAE9D,MAF8D,SAE/C,gBAF+C,GAG7D,MAH6D,CAAA,MAAA,CAAA,GAAA,KAAA;;;;;;AAYjE;AACO,KADK,eACL,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAD2D,IAC3D,CAAN,KAAM,CAAA,UAAA,CAAA,EAAA,IAAA,GAAA,YAAA,CAAA;;;;AAUP;AAaA;;AACG,KAdS,gBAcT,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EACiB,IAAA,EAdb,KAca,CAdP,UAcO,CAAA,CAAA,YAAA,CAAA;CAAjB;;AAoBH;;;;;AAWA;;;AAKQ,KAtCI,SAsCJ,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAAA,CArCL,eAqCK,CArCW,UAqCX,CAAA,GApCL,gBAoCK,CApCY,UAoCZ,CAAA,CAAA,GAAA;EAWN;;;;;;EAOgB,QAAA,CAAA,EAAA,IAAA;AASlB,CAAA;;;;;;;;;;AAWsB,KAtDV,aAsDU,CAAA,eAtDmB,SAsDnB,GAtD+B,SAsD/B,CAAA,GAAA,SArDZ,MAqDY,EAAA;AAStB;;;;;;;;AAgBK,KApEO,mBAoEP,CAAA,eAnEW,SAmEX,GAnEuB,SAmEvB,EAAA,WAAA,OAAA,CAAA,GAAA;EACG;EACQ,KAAA,EAjER,MAiEQ;EAAkB;EAAV,KAAA,EAAA,MAAA;EAAhB;EACH,MAAA,EAxDI,aAwDJ,CAvDH,MAuDG,SAvDY,gBAuDZ,GAvD+B,gBAuD/B,GAvDkD,eAuDlD,CAAA;EAJA;;;;WA5CK;;;;;;;;KASE,kCAEI,uCAKb,+BAEA,kBAAkB,wBAClB,gBAAgB,oBAAoB,QAAQ,aAC5C;;;;;;;;KASS,mCACI,YAAY,iDAaZ,iBAAiB,UAC5B,mBACA,QAAQ,QAAQ,UAAU,4BACvB,YACA,QAAQ,QAAQ,UAAU,aAC7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
let __prismicio_client = require("@prismicio/client");
|
|
3
|
+
|
|
4
|
+
//#region src/createPrismic.ts
|
|
5
|
+
const prismicKey = Symbol.for("@prismicio/vue/plugin");
|
|
6
|
+
/** Creates a Prismic Vue plugin instance that can be used by a Vue app. */
|
|
7
|
+
const createPrismic = (config) => {
|
|
8
|
+
return {
|
|
9
|
+
...config,
|
|
10
|
+
isFilled: __prismicio_client.isFilled,
|
|
11
|
+
install(app) {
|
|
12
|
+
app.provide(prismicKey, this);
|
|
13
|
+
app.config.globalProperties.$prismic = this;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Access the Prismic Vue plugin interface.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const { client, isFilled } = usePrismic()
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const usePrismic = () => {
|
|
27
|
+
return (0, vue.inject)(prismicKey, { componentsConfig: {} });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.createPrismic = createPrismic;
|
|
32
|
+
exports.usePrismic = usePrismic;
|
|
33
|
+
//# sourceMappingURL=createPrismic.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPrismic.cjs","names":[],"sources":["../../src/createPrismic.ts"],"sourcesContent":["import type { CreateClient } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport { type App, type InjectionKey, inject } from \"vue\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport type { VueRichTextComponents } from \"./PrismicRichText\"\nimport type { VueTableComponents } from \"./PrismicTable\"\n\nconst prismicKey = Symbol.for(\n\t\"@prismicio/vue/plugin\",\n) as InjectionKey<PrismicPlugin>\n\n/** Components configuration. */\ntype ComponentsConfig = {\n\t/** The default component rendered for internal URLs. */\n\tlinkInternalComponent?: ComponentOrTagName\n\n\t/** The default component rendered for external URLs. */\n\tlinkExternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The default components or shorthand definitions for Rich Text and Table\n\t * fields.\n\t */\n\tdefaultComponents?: VueRichTextComponents & VueTableComponents\n}\n\n/**\n * Prismic Vue plugin interface accessible through `usePrismic()` and\n * `$prismic`.\n */\nexport type PrismicPlugin = {\n\t/** A Prismic client that can be used to query content from a repository. */\n\tclient: ReturnType<CreateClient>\n\n\t/** Helpers to determine if a field is filled. */\n\tisFilled: typeof isFilled\n\n\t/** @internal */\n\treadonly componentsConfig?: ComponentsConfig\n\n\t/** @internal */\n\tinstall: (app: App) => void\n}\n\n/** Prismic Vue plugin configuration. */\nexport type PrismicPluginConfig = {\n\t/** A Prismic client instance to inject into the Vue app. */\n\tclient: ReturnType<CreateClient>\n\n\t/** Components configuration. */\n\tcomponentsConfig?: ComponentsConfig\n}\n\n/** Creates a Prismic Vue plugin instance that can be used by a Vue app. */\nexport const createPrismic = (config: PrismicPluginConfig): PrismicPlugin => {\n\treturn {\n\t\t...config,\n\t\tisFilled,\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this)\n\t\t\tapp.config.globalProperties.$prismic = this\n\t\t},\n\t}\n}\n\n/**\n * Access the Prismic Vue plugin interface.\n *\n * @example\n *\n * ```typescript\n * const { client, isFilled } = usePrismic()\n * ```\n */\nexport const usePrismic = (): PrismicPlugin => {\n\treturn inject(prismicKey, { componentsConfig: {} } as PrismicPlugin)\n}\n\ndeclare module \"vue\" {\n\texport interface ComponentCustomProperties {\n\t\t/** The Prismic Vue plugin interface. */\n\t\t$prismic: PrismicPlugin\n\t}\n}\n"],"mappings":";;;;AASA,MAAM,aAAa,OAAO,IACzB,wBACA;;AA6CD,MAAa,iBAAiB,WAA+C;AAC5E,QAAO;EACN,GAAG;EACH;EACA,QAAQ,KAAgB;AACvB,OAAI,QAAQ,YAAY,KAAK;AAC7B,OAAI,OAAO,iBAAiB,WAAW;;EAExC;;;;;;;;;;;AAYF,MAAa,mBAAkC;AAC9C,wBAAc,YAAY,EAAE,kBAAkB,EAAE,EAAE,CAAkB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ComponentOrTagName } from "./types.js";
|
|
2
|
+
import { VueRichTextComponents } from "./PrismicRichText/types.js";
|
|
3
|
+
import "./PrismicRichText/index.js";
|
|
4
|
+
import { VueTableComponents } from "./PrismicTable/types.js";
|
|
5
|
+
import "./PrismicTable/index.js";
|
|
6
|
+
import { App } from "vue";
|
|
7
|
+
import { CreateClient, isFilled } from "@prismicio/client";
|
|
8
|
+
|
|
9
|
+
//#region src/createPrismic.d.ts
|
|
10
|
+
/** Components configuration. */
|
|
11
|
+
type ComponentsConfig = {
|
|
12
|
+
/** The default component rendered for internal URLs. */
|
|
13
|
+
linkInternalComponent?: ComponentOrTagName;
|
|
14
|
+
/** The default component rendered for external URLs. */
|
|
15
|
+
linkExternalComponent?: ComponentOrTagName;
|
|
16
|
+
/**
|
|
17
|
+
* The default components or shorthand definitions for Rich Text and Table
|
|
18
|
+
* fields.
|
|
19
|
+
*/
|
|
20
|
+
defaultComponents?: VueRichTextComponents & VueTableComponents;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Prismic Vue plugin interface accessible through `usePrismic()` and
|
|
24
|
+
* `$prismic`.
|
|
25
|
+
*/
|
|
26
|
+
type PrismicPlugin = {
|
|
27
|
+
/** A Prismic client that can be used to query content from a repository. */
|
|
28
|
+
client: ReturnType<CreateClient>;
|
|
29
|
+
/** Helpers to determine if a field is filled. */
|
|
30
|
+
isFilled: typeof isFilled;
|
|
31
|
+
/** @internal */
|
|
32
|
+
readonly componentsConfig?: ComponentsConfig;
|
|
33
|
+
/** @internal */
|
|
34
|
+
install: (app: App) => void;
|
|
35
|
+
};
|
|
36
|
+
/** Prismic Vue plugin configuration. */
|
|
37
|
+
type PrismicPluginConfig = {
|
|
38
|
+
/** A Prismic client instance to inject into the Vue app. */
|
|
39
|
+
client: ReturnType<CreateClient>;
|
|
40
|
+
/** Components configuration. */
|
|
41
|
+
componentsConfig?: ComponentsConfig;
|
|
42
|
+
};
|
|
43
|
+
/** Creates a Prismic Vue plugin instance that can be used by a Vue app. */
|
|
44
|
+
declare const createPrismic: (config: PrismicPluginConfig) => PrismicPlugin;
|
|
45
|
+
/**
|
|
46
|
+
* Access the Prismic Vue plugin interface.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const { client, isFilled } = usePrismic()
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const usePrismic: () => PrismicPlugin;
|
|
55
|
+
declare module "vue" {
|
|
56
|
+
interface ComponentCustomProperties {
|
|
57
|
+
/** The Prismic Vue plugin interface. */
|
|
58
|
+
$prismic: PrismicPlugin;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { PrismicPlugin, PrismicPluginConfig, createPrismic, usePrismic };
|
|
63
|
+
//# sourceMappingURL=createPrismic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPrismic.d.ts","names":[],"sources":["../../src/createPrismic.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAcK,gBAAA;;EAAA,qBAAgB,CAAA,EAEI,kBAFJ;EAEI;EAGA,qBAAA,CAAA,EAAA,kBAAA;EAMJ;;;AAOrB;EAEoB,iBAAA,CAAA,EATC,qBASD,GATyB,kBASzB;CAAX;;;;;AAaG,KAfA,aAAA,GAemB;EAEX;EAAX,MAAA,EAfA,UAeA,CAfW,YAeX,CAAA;EAGW;EAAgB,QAAA,EAAA,OAflB,QAekB;EAIvB;EAoBA,SAAA,gBAAiB,CAAA,EApCD,gBAsC5B;EAAA;EAAA,OAAA,EAAA,CAAA,GAAA,EAnCe,GAmCf,EAAA,GAAA,IAAA;;;AAKwB,KApCb,mBAAA,GAoCa;;UAlChB,WAAW;;qBAGA;;;cAIP,wBAAyB,wBAAsB;;;;;;;;;;cAoB/C,kBAAiB;;;;cAOlB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { inject } from "vue";
|
|
2
|
+
import { isFilled } from "@prismicio/client";
|
|
3
|
+
|
|
4
|
+
//#region src/createPrismic.ts
|
|
5
|
+
const prismicKey = Symbol.for("@prismicio/vue/plugin");
|
|
6
|
+
/** Creates a Prismic Vue plugin instance that can be used by a Vue app. */
|
|
7
|
+
const createPrismic = (config) => {
|
|
8
|
+
return {
|
|
9
|
+
...config,
|
|
10
|
+
isFilled,
|
|
11
|
+
install(app) {
|
|
12
|
+
app.provide(prismicKey, this);
|
|
13
|
+
app.config.globalProperties.$prismic = this;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Access the Prismic Vue plugin interface.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const { client, isFilled } = usePrismic()
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const usePrismic = () => {
|
|
27
|
+
return inject(prismicKey, { componentsConfig: {} });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createPrismic, usePrismic };
|
|
32
|
+
//# sourceMappingURL=createPrismic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPrismic.js","names":[],"sources":["../../src/createPrismic.ts"],"sourcesContent":["import type { CreateClient } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport { type App, type InjectionKey, inject } from \"vue\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport type { VueRichTextComponents } from \"./PrismicRichText\"\nimport type { VueTableComponents } from \"./PrismicTable\"\n\nconst prismicKey = Symbol.for(\n\t\"@prismicio/vue/plugin\",\n) as InjectionKey<PrismicPlugin>\n\n/** Components configuration. */\ntype ComponentsConfig = {\n\t/** The default component rendered for internal URLs. */\n\tlinkInternalComponent?: ComponentOrTagName\n\n\t/** The default component rendered for external URLs. */\n\tlinkExternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The default components or shorthand definitions for Rich Text and Table\n\t * fields.\n\t */\n\tdefaultComponents?: VueRichTextComponents & VueTableComponents\n}\n\n/**\n * Prismic Vue plugin interface accessible through `usePrismic()` and\n * `$prismic`.\n */\nexport type PrismicPlugin = {\n\t/** A Prismic client that can be used to query content from a repository. */\n\tclient: ReturnType<CreateClient>\n\n\t/** Helpers to determine if a field is filled. */\n\tisFilled: typeof isFilled\n\n\t/** @internal */\n\treadonly componentsConfig?: ComponentsConfig\n\n\t/** @internal */\n\tinstall: (app: App) => void\n}\n\n/** Prismic Vue plugin configuration. */\nexport type PrismicPluginConfig = {\n\t/** A Prismic client instance to inject into the Vue app. */\n\tclient: ReturnType<CreateClient>\n\n\t/** Components configuration. */\n\tcomponentsConfig?: ComponentsConfig\n}\n\n/** Creates a Prismic Vue plugin instance that can be used by a Vue app. */\nexport const createPrismic = (config: PrismicPluginConfig): PrismicPlugin => {\n\treturn {\n\t\t...config,\n\t\tisFilled,\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this)\n\t\t\tapp.config.globalProperties.$prismic = this\n\t\t},\n\t}\n}\n\n/**\n * Access the Prismic Vue plugin interface.\n *\n * @example\n *\n * ```typescript\n * const { client, isFilled } = usePrismic()\n * ```\n */\nexport const usePrismic = (): PrismicPlugin => {\n\treturn inject(prismicKey, { componentsConfig: {} } as PrismicPlugin)\n}\n\ndeclare module \"vue\" {\n\texport interface ComponentCustomProperties {\n\t\t/** The Prismic Vue plugin interface. */\n\t\t$prismic: PrismicPlugin\n\t}\n}\n"],"mappings":";;;;AASA,MAAM,aAAa,OAAO,IACzB,wBACA;;AA6CD,MAAa,iBAAiB,WAA+C;AAC5E,QAAO;EACN,GAAG;EACH;EACA,QAAQ,KAAgB;AACvB,OAAI,QAAQ,YAAY,KAAK;AAC7B,OAAI,OAAO,iBAAiB,WAAW;;EAExC;;;;;;;;;;;AAYF,MAAa,mBAAkC;AAC9C,QAAO,OAAO,YAAY,EAAE,kBAAkB,EAAE,EAAE,CAAkB"}
|
|
@@ -8,13 +8,9 @@
|
|
|
8
8
|
* @returns `true` if `url` is internal, `false` otherwise
|
|
9
9
|
*/
|
|
10
10
|
const isInternalURL = (url) => {
|
|
11
|
-
/**
|
|
12
|
-
* @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
|
|
13
|
-
*/
|
|
11
|
+
/** @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1} */
|
|
14
12
|
const isInternal = /^\/(?!\/)/.test(url);
|
|
15
|
-
/**
|
|
16
|
-
* @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1}
|
|
17
|
-
*/
|
|
13
|
+
/** @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1} */
|
|
18
14
|
const isSpecialLink = !isInternal && !/^https?:\/\//i.test(url);
|
|
19
15
|
return isInternal && !isSpecialLink;
|
|
20
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInternalURL.cjs","names":[],"sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external\n *\n * @returns `true` if `url` is internal, `false` otherwise\n */\n// TODO: This does not detect all relative URLs as internal, such as `about` or `./about`. This function assumes relative URLs start with a \"/\"`.\nexport const isInternalURL = (url: string): boolean => {\n\t
|
|
1
|
+
{"version":3,"file":"isInternalURL.cjs","names":[],"sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external\n *\n * @returns `true` if `url` is internal, `false` otherwise\n */\n// TODO: This does not detect all relative URLs as internal, such as `about` or `./about`. This function assumes relative URLs start with a \"/\"`.\nexport const isInternalURL = (url: string): boolean => {\n\t/** @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1} */\n\tconst isInternal = /^\\/(?!\\/)/.test(url)\n\t/** @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1} */\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//i.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,iBAAiB,QAAyB;;CAEtD,MAAM,aAAa,YAAY,KAAK,IAAI;;CAExC,MAAM,gBAAgB,CAAC,cAAc,CAAC,gBAAgB,KAAK,IAAI;AAE/D,QAAO,cAAc,CAAC"}
|
|
@@ -7,13 +7,9 @@
|
|
|
7
7
|
* @returns `true` if `url` is internal, `false` otherwise
|
|
8
8
|
*/
|
|
9
9
|
const isInternalURL = (url) => {
|
|
10
|
-
/**
|
|
11
|
-
* @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
|
|
12
|
-
*/
|
|
10
|
+
/** @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1} */
|
|
13
11
|
const isInternal = /^\/(?!\/)/.test(url);
|
|
14
|
-
/**
|
|
15
|
-
* @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1}
|
|
16
|
-
*/
|
|
12
|
+
/** @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1} */
|
|
17
13
|
const isSpecialLink = !isInternal && !/^https?:\/\//i.test(url);
|
|
18
14
|
return isInternal && !isSpecialLink;
|
|
19
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInternalURL.js","names":[],"sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external\n *\n * @returns `true` if `url` is internal, `false` otherwise\n */\n// TODO: This does not detect all relative URLs as internal, such as `about` or `./about`. This function assumes relative URLs start with a \"/\"`.\nexport const isInternalURL = (url: string): boolean => {\n\t
|
|
1
|
+
{"version":3,"file":"isInternalURL.js","names":[],"sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external\n *\n * @returns `true` if `url` is internal, `false` otherwise\n */\n// TODO: This does not detect all relative URLs as internal, such as `about` or `./about`. This function assumes relative URLs start with a \"/\"`.\nexport const isInternalURL = (url: string): boolean => {\n\t/** @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1} */\n\tconst isInternal = /^\\/(?!\\/)/.test(url)\n\t/** @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1} */\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//i.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,iBAAiB,QAAyB;;CAEtD,MAAM,aAAa,YAAY,KAAK,IAAI;;CAExC,MAAM,gBAAgB,CAAC,cAAc,CAAC,gBAAgB,KAAK,IAAI;AAE/D,QAAO,cAAc,CAAC"}
|
package/dist/src/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","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.cjs","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/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-pr.
|
|
3
|
+
"version": "5.3.0-pr.89.d0f4ac2",
|
|
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,9 +10,7 @@ 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
15
|
/** The Prismic image field or thumbnail to render. */
|
|
18
16
|
field: ImageField | ImageField<string>
|
|
@@ -59,15 +57,14 @@ export type PrismicImageProps = {
|
|
|
59
57
|
} & (
|
|
60
58
|
| {
|
|
61
59
|
/**
|
|
62
|
-
* Widths (in pixels) used to build a `srcset` value for the image
|
|
63
|
-
* field.
|
|
60
|
+
* Widths (in pixels) used to build a `srcset` value for the image field.
|
|
64
61
|
*
|
|
65
62
|
* If omitted or set to `"defaults"`, the following widths will be used:
|
|
66
63
|
* 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
|
|
67
64
|
*
|
|
68
|
-
* If the image field contains responsive views, each responsive view
|
|
69
|
-
*
|
|
70
|
-
*
|
|
65
|
+
* If the image field contains responsive views, each responsive view can
|
|
66
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
67
|
+
* as the `widths` prop.
|
|
71
68
|
*/
|
|
72
69
|
widths?:
|
|
73
70
|
| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
|
package/src/PrismicLink.vue
CHANGED
|
@@ -12,24 +12,18 @@ import { isInternalURL } from "./lib/isInternalURL"
|
|
|
12
12
|
|
|
13
13
|
import type { ComponentOrTagName } from "./types"
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
15
|
+
import { usePrismic } from "./createPrismic"
|
|
16
|
+
|
|
17
|
+
/** The default component rendered for internal URLs. */
|
|
18
18
|
const defaultInternalComponent = "router-link"
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* The default component rendered for external URLs.
|
|
22
|
-
*/
|
|
20
|
+
/** The default component rendered for external URLs. */
|
|
23
21
|
const defaultExternalComponent = "a"
|
|
24
22
|
|
|
25
|
-
/**
|
|
26
|
-
* The default rel attribute rendered for external URLs.
|
|
27
|
-
*/
|
|
23
|
+
/** The default rel attribute rendered for external URLs. */
|
|
28
24
|
const defaultExternalRelAttribute = "noreferrer"
|
|
29
25
|
|
|
30
|
-
/**
|
|
31
|
-
* Props for `<PrismicLink />`.
|
|
32
|
-
*/
|
|
26
|
+
/** Props for `<PrismicLink />`. */
|
|
33
27
|
export type PrismicLinkProps = {
|
|
34
28
|
/**
|
|
35
29
|
* The link resolver used to resolve links.
|
|
@@ -81,6 +75,8 @@ export type PrismicLinkProps = {
|
|
|
81
75
|
const props = defineProps<PrismicLinkProps>()
|
|
82
76
|
defineOptions({ name: "PrismicLink" })
|
|
83
77
|
|
|
78
|
+
const { componentsConfig } = usePrismic()
|
|
79
|
+
|
|
84
80
|
const rawAttrs = computed(() => {
|
|
85
81
|
return asLinkAttrs(props.field || props.document, {
|
|
86
82
|
linkResolver: props.linkResolver,
|
|
@@ -96,8 +92,12 @@ const rawAttrs = computed(() => {
|
|
|
96
92
|
|
|
97
93
|
const component = computed(() => {
|
|
98
94
|
return isInternalURL(rawAttrs.value.href || "")
|
|
99
|
-
? props.internalComponent ||
|
|
100
|
-
|
|
95
|
+
? props.internalComponent ||
|
|
96
|
+
componentsConfig?.linkInternalComponent ||
|
|
97
|
+
defaultInternalComponent
|
|
98
|
+
: props.externalComponent ||
|
|
99
|
+
componentsConfig?.linkExternalComponent ||
|
|
100
|
+
defaultExternalComponent
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.
|
|
@@ -8,19 +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
|
-
|
|
15
|
-
|
|
14
|
+
InternalVueRichTextComponents,
|
|
15
|
+
VueRichTextComponent,
|
|
16
|
+
VueRichTextComponents,
|
|
16
17
|
} from "./types"
|
|
17
18
|
|
|
19
|
+
import { usePrismic } from "../createPrismic"
|
|
20
|
+
|
|
18
21
|
import PrismicRichTextDefaultComponent from "./PrismicRichTextDefaultComponent.vue"
|
|
19
22
|
import PrismicRichTextSerialize from "./PrismicRichTextSerialize.vue"
|
|
20
23
|
|
|
21
|
-
/**
|
|
22
|
-
* Props for `<PrismicRichText />`.
|
|
23
|
-
*/
|
|
24
|
+
/** Props for `<PrismicRichText />`. */
|
|
24
25
|
export type PrismicRichTextProps = {
|
|
25
26
|
/** The Prismic rich text field to render. */
|
|
26
27
|
field: RichTextField | null | undefined
|
|
@@ -37,7 +38,8 @@ export type PrismicRichTextProps = {
|
|
|
37
38
|
linkResolver?: LinkResolverFunction
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* An object that maps a rich text block type to a Vue component or a
|
|
41
|
+
* An object that maps a rich text block type to a Vue component or a
|
|
42
|
+
* shorthand definition.
|
|
41
43
|
*
|
|
42
44
|
* @example
|
|
43
45
|
*
|
|
@@ -49,7 +51,7 @@ export type PrismicRichTextProps = {
|
|
|
49
51
|
* }
|
|
50
52
|
* ```
|
|
51
53
|
*/
|
|
52
|
-
components?:
|
|
54
|
+
components?: VueRichTextComponents
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* The value to be rendered when the field is empty. If a fallback is not
|
|
@@ -78,12 +80,21 @@ const props = defineProps({
|
|
|
78
80
|
})
|
|
79
81
|
defineOptions({ name: "PrismicRichText" })
|
|
80
82
|
|
|
83
|
+
const { componentsConfig } = usePrismic()
|
|
84
|
+
|
|
85
|
+
const resolvedComponents = computed<VueRichTextComponents>(() => {
|
|
86
|
+
return { ...componentsConfig?.defaultComponents, ...props.components }
|
|
87
|
+
})
|
|
88
|
+
|
|
81
89
|
const children = computed(() => {
|
|
82
90
|
return asTree(props.field || []).children
|
|
83
91
|
})
|
|
84
92
|
|
|
85
93
|
function getInternalComponent(type: keyof typeof RichTextNodeType) {
|
|
86
|
-
const maybeComponentOrShorthand =
|
|
94
|
+
const maybeComponentOrShorthand = resolvedComponents.value?.[type] as
|
|
95
|
+
| VueRichTextComponent
|
|
96
|
+
| VueComponentShorthand
|
|
97
|
+
| undefined
|
|
87
98
|
|
|
88
99
|
if (isVueComponent(maybeComponentOrShorthand)) {
|
|
89
100
|
return { is: maybeComponentOrShorthand }
|
|
@@ -91,14 +102,12 @@ function getInternalComponent(type: keyof typeof RichTextNodeType) {
|
|
|
91
102
|
|
|
92
103
|
return {
|
|
93
104
|
is: PrismicRichTextDefaultComponent,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
shorthand: maybeComponentOrShorthand as VueShorthand,
|
|
97
|
-
},
|
|
105
|
+
linkResolver: props.linkResolver,
|
|
106
|
+
shorthand: maybeComponentOrShorthand,
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
109
|
|
|
101
|
-
const internalComponents = computed<
|
|
110
|
+
const internalComponents = computed<InternalVueRichTextComponents>(() => {
|
|
102
111
|
return {
|
|
103
112
|
heading1: getInternalComponent("heading1"),
|
|
104
113
|
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"
|