@prismicio/vue 5.2.0 → 5.3.0

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.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/dist/PrismicEmbed.vue.js +1 -1
  3. package/dist/PrismicImage.vue.cjs +31 -3
  4. package/dist/PrismicImage.vue.cjs.map +1 -1
  5. package/dist/PrismicImage.vue.d.ts +70 -0
  6. package/dist/PrismicImage.vue.js +32 -4
  7. package/dist/PrismicImage.vue.js.map +1 -1
  8. package/dist/PrismicLink.vue.js +1 -1
  9. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs +16 -6
  10. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs.map +1 -1
  11. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.d.ts +34 -4
  12. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js +17 -7
  13. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js.map +1 -1
  14. package/dist/PrismicRichText/PrismicRichText.vue.cjs +26 -14
  15. package/dist/PrismicRichText/PrismicRichText.vue.cjs.map +1 -1
  16. package/dist/PrismicRichText/PrismicRichText.vue.d.ts +40 -1
  17. package/dist/PrismicRichText/PrismicRichText.vue.js +27 -15
  18. package/dist/PrismicRichText/PrismicRichText.vue.js.map +1 -1
  19. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js +1 -1
  20. package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js +1 -1
  21. package/dist/PrismicTable/PrismicTable.vue.js +1 -1
  22. package/dist/PrismicTable/PrismicTableDefaultComponents.js +1 -1
  23. package/dist/PrismicTable/PrismicTableRow.vue.js +1 -1
  24. package/dist/PrismicText.vue.js +1 -1
  25. package/dist/SliceZone/SliceZone.vue.js +1 -1
  26. package/dist/createPrismic.js +1 -1
  27. package/dist/lib/Wrapper.vue.js +1 -1
  28. package/dist/package.json.cjs +1 -1
  29. package/dist/package.json.js +1 -1
  30. package/package.json +20 -20
  31. package/src/PrismicImage.vue +54 -1
  32. package/src/PrismicRichText/DeprecatedPrismicRichText.vue +22 -7
  33. package/src/PrismicRichText/PrismicRichText.vue +27 -1
package/README.md CHANGED
@@ -73,7 +73,7 @@ For more clarity on this project and its structure you can also check out the de
73
73
 
74
74
  <!-- Replace link with a more useful one if available -->
75
75
 
76
- [prismic-docs]: https://prismic.io/docs/technologies/vuejs
76
+ [prismic-docs]: https://prismic.io/docs/technical-reference/prismicio-vue/v5
77
77
  [changelog]: ./CHANGELOG.md
78
78
  [contributing]: ./CONTRIBUTING.md
79
79
  [vue]: https://v3.vuejs.org
@@ -1,4 +1,4 @@
1
- import { defineComponent, unref, openBlock, createBlock, resolveDynamicComponent, createCommentVNode } from "vue";
1
+ import { defineComponent, createBlock, createCommentVNode, unref, openBlock, resolveDynamicComponent } from "vue";
2
2
  import { isFilled } from "@prismicio/client";
3
3
  const defaultWrapper = "div";
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -4,7 +4,7 @@ const client = require("@prismicio/client");
4
4
  const esmEnv = require("esm-env");
5
5
  const devMsg = require("./lib/devMsg.cjs");
6
6
  const usePrismic = require("./usePrismic.cjs");
7
- const _hoisted_1 = ["src", "srcset", "alt"];
7
+ const _hoisted_1 = ["src", "srcset", "alt", "width", "height"];
8
8
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
9
9
  ...{ name: "PrismicImage" },
10
10
  __name: "PrismicImage",
@@ -13,6 +13,8 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
13
13
  imgixParams: {},
14
14
  alt: {},
15
15
  fallbackAlt: {},
16
+ width: {},
17
+ height: {},
16
18
  widths: {},
17
19
  pixelDensities: {}
18
20
  },
@@ -42,6 +44,18 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
42
44
  }
43
45
  });
44
46
  }
47
+ const castInt = (input) => {
48
+ if (typeof input === "number" || typeof input === "undefined") {
49
+ return input;
50
+ } else {
51
+ const parsed = Number.parseInt(input);
52
+ if (Number.isNaN(parsed)) {
53
+ return void 0;
54
+ } else {
55
+ return parsed;
56
+ }
57
+ }
58
+ };
45
59
  const image = vue.computed(() => {
46
60
  var _a, _b;
47
61
  if (!client.isFilled.imageThumbnail(props.field)) {
@@ -64,10 +78,22 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
64
78
  src = res.src;
65
79
  srcSet = res.srcset;
66
80
  }
81
+ const ar = props.field.dimensions.width / props.field.dimensions.height;
82
+ const castedWidth = castInt(props.width);
83
+ const castedHeight = castInt(props.height);
84
+ let resolvedWidth = castedWidth ?? props.field.dimensions.width;
85
+ let resolvedHeight = castedHeight ?? props.field.dimensions.height;
86
+ if (castedWidth != null && castedHeight == null) {
87
+ resolvedHeight = castedWidth / ar;
88
+ } else if (castedWidth == null && castedHeight != null) {
89
+ resolvedWidth = castedHeight * ar;
90
+ }
67
91
  return {
68
92
  src,
69
93
  srcSet,
70
- alt: props.alt ?? (props.field.alt || props.fallbackAlt)
94
+ alt: props.alt ?? (props.field.alt || props.fallbackAlt),
95
+ width: Math.round(resolvedWidth),
96
+ height: Math.round(resolvedHeight)
71
97
  };
72
98
  });
73
99
  return (_ctx, _cache) => {
@@ -75,7 +101,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
75
101
  key: 0,
76
102
  src: image.value.src,
77
103
  srcset: image.value.srcSet,
78
- alt: image.value.alt
104
+ alt: image.value.alt,
105
+ width: image.value.width,
106
+ height: image.value.height
79
107
  }, null, 8, _hoisted_1)) : vue.createCommentVNode("", true);
80
108
  };
81
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.vue.cjs","sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t}\n})\n</script>\n\n<template>\n\t<img v-if=\"image\" :src=\"image.src\" :srcset=\"image.srcSet\" :alt=\"image.alt\" />\n</template>\n"],"names":["usePrismic","DEV","watchEffect","devMsg","computed","isFilled","asImageWidthSrcSet","asImagePixelDensitySrcSet"],"mappings":";;;;;;;;;;;;;;;;;;;AAuFA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAE/B,QAAIC,YAAK;AACRC,UAAAA,YAAY,MAAM;AACjB,YAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAC9C,kBAAA;AAAA,YACP,qQAAqQC,OAAA;AAAA,cACpQ;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGD,YAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAAI;AAC9D,kBAAA;AAAA,YACP,qSAAqSA,OAAA;AAAA,cACpS;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGG,YAAA,MAAM,UAAU,MAAM,gBAAgB;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;AAGI,UAAA,QAAQC,IAAAA,SAAS,MAAM;;AAC5B,UAAI,CAACC,OAAAA,SAAS,eAAe,MAAM,KAAK,GAAG;AAC1C;AAAA,MAAA;AAGG,UAAA;AACA,UAAA;AACJ,UAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;AACpC,cAAA,MAAMC,OAAAA,mBAAmB,MAAM,OAAO;AAAA,UAC3C,GAAG,MAAM;AAAA,UACT,QACC,MAAM,WAAW,cACd,aAAQ,eAAR,mBAAoB,2BACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA,WACH,MAAM,gBAAgB;AAC1B,cAAA,MAAMC,OAAAA,0BAA0B,MAAM,OAAO;AAAA,UAClD,GAAG,MAAM;AAAA,UACT,gBACC,MAAM,mBAAmB,cACtB,aAAQ,eAAR,mBAAoB,kCACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA;AAGP,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;AAAA,MAC7C;AAAA,IAAA,CACA;;;;;;;;;;;;"}
1
+ {"version":3,"file":"PrismicImage.vue.cjs","sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"names":["usePrismic","DEV","watchEffect","devMsg","computed","isFilled","asImageWidthSrcSet","asImagePixelDensitySrcSet"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuGA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAE/B,QAAIC,YAAK;AACRC,UAAAA,YAAY,MAAM;AACjB,YAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAC9C,kBAAA;AAAA,YACP,qQAAqQC,OAAA;AAAA,cACpQ;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGD,YAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAAI;AAC9D,kBAAA;AAAA,YACP,qSAAqSA,OAAA;AAAA,cACpS;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGG,YAAA,MAAM,UAAU,MAAM,gBAAgB;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;AAGI,UAAA,UAAU,CAAC,UAA2D;AAC3E,UAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa;AACvD,eAAA;AAAA,MAAA,OACD;AACA,cAAA,SAAS,OAAO,SAAS,KAAK;AAEhC,YAAA,OAAO,MAAM,MAAM,GAAG;AAClB,iBAAA;AAAA,QAAA,OACD;AACC,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAEF;AAEM,UAAA,QAAQC,IAAAA,SAAS,MAAM;;AAC5B,UAAI,CAACC,OAAAA,SAAS,eAAe,MAAM,KAAK,GAAG;AAC1C;AAAA,MAAA;AAGG,UAAA;AACA,UAAA;AACJ,UAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;AACpC,cAAA,MAAMC,OAAAA,mBAAmB,MAAM,OAAO;AAAA,UAC3C,GAAG,MAAM;AAAA,UACT,QACC,MAAM,WAAW,cACd,aAAQ,eAAR,mBAAoB,2BACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA,WACH,MAAM,gBAAgB;AAC1B,cAAA,MAAMC,OAAAA,0BAA0B,MAAM,OAAO;AAAA,UAClD,GAAG,MAAM;AAAA,UACT,gBACC,MAAM,mBAAmB,cACtB,aAAQ,eAAR,mBAAoB,kCACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA;AAGd,YAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;AAE3D,YAAA,cAAc,QAAQ,MAAM,KAAK;AACjC,YAAA,eAAe,QAAQ,MAAM,MAAM;AAEzC,UAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;AAC1D,UAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;AAExD,UAAA,eAAe,QAAQ,gBAAgB,MAAM;AAChD,yBAAiB,cAAc;AAAA,MACrB,WAAA,eAAe,QAAQ,gBAAgB,MAAM;AACvD,wBAAgB,eAAe;AAAA,MAAA;AAGzB,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;AAAA,QAC5C,OAAO,KAAK,MAAM,aAAa;AAAA,QAC/B,QAAQ,KAAK,MAAM,cAAc;AAAA,MAClC;AAAA,IAAA,CACA;;;;;;;;;;;;;;"}
@@ -28,6 +28,20 @@ export type PrismicImageProps = {
28
28
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
29
29
  */
30
30
  fallbackAlt?: "";
31
+ /**
32
+ * The width attribute of the image element.
33
+ *
34
+ * See:
35
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
36
+ */
37
+ width?: number | string;
38
+ /**
39
+ * The height attribute of the image element.
40
+ *
41
+ * See:
42
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
43
+ */
44
+ height?: number | string;
31
45
  } & ({
32
46
  /**
33
47
  * Widths used to build a `srcset` value for the image field.
@@ -84,6 +98,20 @@ declare const _default: import('vue').DefineComponent<({
84
98
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
85
99
  */
86
100
  fallbackAlt?: "";
101
+ /**
102
+ * The width attribute of the image element.
103
+ *
104
+ * See:
105
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
106
+ */
107
+ width?: number | string;
108
+ /**
109
+ * The height attribute of the image element.
110
+ *
111
+ * See:
112
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
113
+ */
114
+ height?: number | string;
87
115
  } & {
88
116
  /**
89
117
  * Widths used to build a `srcset` value for the image field.
@@ -127,6 +155,20 @@ declare const _default: import('vue').DefineComponent<({
127
155
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
128
156
  */
129
157
  fallbackAlt?: "";
158
+ /**
159
+ * The width attribute of the image element.
160
+ *
161
+ * See:
162
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
163
+ */
164
+ width?: number | string;
165
+ /**
166
+ * The height attribute of the image element.
167
+ *
168
+ * See:
169
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
170
+ */
171
+ height?: number | string;
130
172
  } & {
131
173
  /**
132
174
  * Not used when the `widths` prop is used.
@@ -165,6 +207,20 @@ declare const _default: import('vue').DefineComponent<({
165
207
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
166
208
  */
167
209
  fallbackAlt?: "";
210
+ /**
211
+ * The width attribute of the image element.
212
+ *
213
+ * See:
214
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
215
+ */
216
+ width?: number | string;
217
+ /**
218
+ * The height attribute of the image element.
219
+ *
220
+ * See:
221
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
222
+ */
223
+ height?: number | string;
168
224
  } & {
169
225
  /**
170
226
  * Widths used to build a `srcset` value for the image field.
@@ -208,6 +264,20 @@ declare const _default: import('vue').DefineComponent<({
208
264
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
209
265
  */
210
266
  fallbackAlt?: "";
267
+ /**
268
+ * The width attribute of the image element.
269
+ *
270
+ * See:
271
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
272
+ */
273
+ width?: number | string;
274
+ /**
275
+ * The height attribute of the image element.
276
+ *
277
+ * See:
278
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
279
+ */
280
+ height?: number | string;
211
281
  } & {
212
282
  /**
213
283
  * Not used when the `widths` prop is used.
@@ -1,9 +1,9 @@
1
- import { defineComponent, watchEffect, computed, openBlock, createElementBlock, createCommentVNode } from "vue";
1
+ import { defineComponent, watchEffect, computed, createElementBlock, createCommentVNode, openBlock } from "vue";
2
2
  import { isFilled, asImageWidthSrcSet, asImagePixelDensitySrcSet } from "@prismicio/client";
3
3
  import { DEV } from "esm-env";
4
4
  import { devMsg } from "./lib/devMsg.js";
5
5
  import { usePrismic } from "./usePrismic.js";
6
- const _hoisted_1 = ["src", "srcset", "alt"];
6
+ const _hoisted_1 = ["src", "srcset", "alt", "width", "height"];
7
7
  const _sfc_main = /* @__PURE__ */ defineComponent({
8
8
  ...{ name: "PrismicImage" },
9
9
  __name: "PrismicImage",
@@ -12,6 +12,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  imgixParams: {},
13
13
  alt: {},
14
14
  fallbackAlt: {},
15
+ width: {},
16
+ height: {},
15
17
  widths: {},
16
18
  pixelDensities: {}
17
19
  },
@@ -41,6 +43,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
41
43
  }
42
44
  });
43
45
  }
46
+ const castInt = (input) => {
47
+ if (typeof input === "number" || typeof input === "undefined") {
48
+ return input;
49
+ } else {
50
+ const parsed = Number.parseInt(input);
51
+ if (Number.isNaN(parsed)) {
52
+ return void 0;
53
+ } else {
54
+ return parsed;
55
+ }
56
+ }
57
+ };
44
58
  const image = computed(() => {
45
59
  var _a, _b;
46
60
  if (!isFilled.imageThumbnail(props.field)) {
@@ -63,10 +77,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
63
77
  src = res.src;
64
78
  srcSet = res.srcset;
65
79
  }
80
+ const ar = props.field.dimensions.width / props.field.dimensions.height;
81
+ const castedWidth = castInt(props.width);
82
+ const castedHeight = castInt(props.height);
83
+ let resolvedWidth = castedWidth ?? props.field.dimensions.width;
84
+ let resolvedHeight = castedHeight ?? props.field.dimensions.height;
85
+ if (castedWidth != null && castedHeight == null) {
86
+ resolvedHeight = castedWidth / ar;
87
+ } else if (castedWidth == null && castedHeight != null) {
88
+ resolvedWidth = castedHeight * ar;
89
+ }
66
90
  return {
67
91
  src,
68
92
  srcSet,
69
- alt: props.alt ?? (props.field.alt || props.fallbackAlt)
93
+ alt: props.alt ?? (props.field.alt || props.fallbackAlt),
94
+ width: Math.round(resolvedWidth),
95
+ height: Math.round(resolvedHeight)
70
96
  };
71
97
  });
72
98
  return (_ctx, _cache) => {
@@ -74,7 +100,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
74
100
  key: 0,
75
101
  src: image.value.src,
76
102
  srcset: image.value.srcSet,
77
- alt: image.value.alt
103
+ alt: image.value.alt,
104
+ width: image.value.width,
105
+ height: image.value.height
78
106
  }, null, 8, _hoisted_1)) : createCommentVNode("", true);
79
107
  };
80
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.vue.js","sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t}\n})\n</script>\n\n<template>\n\t<img v-if=\"image\" :src=\"image.src\" :srcset=\"image.srcSet\" :alt=\"image.alt\" />\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuFA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAE/B,QAAI,KAAK;AACR,kBAAY,MAAM;AACjB,YAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAC9C,kBAAA;AAAA,YACP,qQAAqQ;AAAA,cACpQ;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGD,YAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAAI;AAC9D,kBAAA;AAAA,YACP,qSAAqS;AAAA,cACpS;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGG,YAAA,MAAM,UAAU,MAAM,gBAAgB;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;AAGI,UAAA,QAAQ,SAAS,MAAM;;AAC5B,UAAI,CAAC,SAAS,eAAe,MAAM,KAAK,GAAG;AAC1C;AAAA,MAAA;AAGG,UAAA;AACA,UAAA;AACJ,UAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;AACpC,cAAA,MAAM,mBAAmB,MAAM,OAAO;AAAA,UAC3C,GAAG,MAAM;AAAA,UACT,QACC,MAAM,WAAW,cACd,aAAQ,eAAR,mBAAoB,2BACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA,WACH,MAAM,gBAAgB;AAC1B,cAAA,MAAM,0BAA0B,MAAM,OAAO;AAAA,UAClD,GAAG,MAAM;AAAA,UACT,gBACC,MAAM,mBAAmB,cACtB,aAAQ,eAAR,mBAAoB,kCACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA;AAGP,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;AAAA,MAC7C;AAAA,IAAA,CACA;;;;;;;;;;;"}
1
+ {"version":3,"file":"PrismicImage.vue.js","sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAuGA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAE/B,QAAI,KAAK;AACR,kBAAY,MAAM;AACjB,YAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAC9C,kBAAA;AAAA,YACP,qQAAqQ;AAAA,cACpQ;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGD,YAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAAI;AAC9D,kBAAA;AAAA,YACP,qSAAqS;AAAA,cACpS;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGG,YAAA,MAAM,UAAU,MAAM,gBAAgB;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;AAGI,UAAA,UAAU,CAAC,UAA2D;AAC3E,UAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa;AACvD,eAAA;AAAA,MAAA,OACD;AACA,cAAA,SAAS,OAAO,SAAS,KAAK;AAEhC,YAAA,OAAO,MAAM,MAAM,GAAG;AAClB,iBAAA;AAAA,QAAA,OACD;AACC,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAEF;AAEM,UAAA,QAAQ,SAAS,MAAM;;AAC5B,UAAI,CAAC,SAAS,eAAe,MAAM,KAAK,GAAG;AAC1C;AAAA,MAAA;AAGG,UAAA;AACA,UAAA;AACJ,UAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;AACpC,cAAA,MAAM,mBAAmB,MAAM,OAAO;AAAA,UAC3C,GAAG,MAAM;AAAA,UACT,QACC,MAAM,WAAW,cACd,aAAQ,eAAR,mBAAoB,2BACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA,WACH,MAAM,gBAAgB;AAC1B,cAAA,MAAM,0BAA0B,MAAM,OAAO;AAAA,UAClD,GAAG,MAAM;AAAA,UACT,gBACC,MAAM,mBAAmB,cACtB,aAAQ,eAAR,mBAAoB,kCACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA;AAGd,YAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;AAE3D,YAAA,cAAc,QAAQ,MAAM,KAAK;AACjC,YAAA,eAAe,QAAQ,MAAM,MAAM;AAEzC,UAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;AAC1D,UAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;AAExD,UAAA,eAAe,QAAQ,gBAAgB,MAAM;AAChD,yBAAiB,cAAc;AAAA,MACrB,WAAA,eAAe,QAAQ,gBAAgB,MAAM;AACvD,wBAAgB,eAAe;AAAA,MAAA;AAGzB,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;AAAA,QAC5C,OAAO,KAAK,MAAM,aAAa;AAAA,QAC/B,QAAQ,KAAK,MAAM,cAAc;AAAA,MAClC;AAAA,IAAA,CACA;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, openBlock, createBlock, resolveDynamicComponent, normalizeProps, guardReactiveProps, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
1
+ import { defineComponent, computed, createBlock, openBlock, resolveDynamicComponent, normalizeProps, guardReactiveProps, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
2
2
  import { asLinkAttrs } from "@prismicio/client";
3
3
  import { isInternalURL } from "./lib/isInternalURL.js";
4
4
  import { usePrismic } from "./usePrismic.js";
@@ -11,11 +11,21 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
11
11
  ...{ name: "DeprecatedPrismicRichText" },
12
12
  __name: "DeprecatedPrismicRichText",
13
13
  props: {
14
- field: {},
15
- linkResolver: {},
16
- serializer: { type: Function },
17
- wrapper: {},
18
- fallback: {}
14
+ field: {
15
+ type: Array
16
+ },
17
+ fallback: {
18
+ type: String
19
+ },
20
+ linkResolver: {
21
+ type: Function
22
+ },
23
+ serializer: {
24
+ type: [Object, Function]
25
+ },
26
+ wrapper: {
27
+ type: [String, Object, Function]
28
+ }
19
29
  },
20
30
  setup(__props) {
21
31
  const props = __props;
@@ -77,7 +87,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
77
87
  removeListeners();
78
88
  });
79
89
  return (_ctx, _cache) => {
80
- return vue.unref(client.isFilled).richText(_ctx.field) || _ctx.fallback ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.wrapper || defaultWrapper), {
90
+ return vue.unref(client.isFilled).richText(__props.field) || __props.fallback ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(__props.wrapper || defaultWrapper), {
81
91
  key: 0,
82
92
  ref_key: "root",
83
93
  ref: root,
@@ -1 +1 @@
1
- {"version":3,"file":"DeprecatedPrismicRichText.vue.cjs","sources":["../../src/PrismicRichText/DeprecatedPrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n// TODO: Remove in v6\nimport { asHTML, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport type { Component } from \"vue\"\nimport {\n\tcomputed,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\twatch,\n} from \"vue\"\nimport { routerKey } from \"vue-router\"\n\nimport { devMsg } from \"../lib/devMsg\"\nimport { isInternalURL } from \"../lib/isInternalURL\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport type { PrismicRichTextProps } from \"./PrismicRichText.vue\"\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\"\n\nconst props = defineProps<\n\tPick<\n\t\tPrismicRichTextProps,\n\t\t\"field\" | \"linkResolver\" | \"serializer\" | \"wrapper\"\n\t> & { fallback?: string }\n>()\ndefineOptions({ name: \"DeprecatedPrismicRichText\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\tonMounted(() => {\n\t\tconsole.warn(\n\t\t\t`[PrismicRichText] You're using the deprecated version of \\`<PrismicRichText>\\` because either the \\`serializer\\` prop or the plugin \\`richTextSerializer\\` option were provided. This API will be removed in a future major. For more details, see ${devMsg(\n\t\t\t\t\"html-serialization-is-deprecated-with-prismic-rich-text\",\n\t\t\t)}`,\n\t\t)\n\t})\n}\n\nconst html = computed(() => {\n\tif (!isFilled.richText(props.field)) {\n\t\treturn props.fallback ?? \"\"\n\t}\n\n\tconst linkResolver = props.linkResolver ?? options.linkResolver\n\tconst serializer = props.serializer ?? options.richTextSerializer\n\n\treturn asHTML(props.field, { linkResolver, serializer })\n})\n\n// Internal links handling\nconst root = ref<HTMLElement | Comment | Component | null>(null)\n\nconst maybeRouter = inject(routerKey, null)\n\ntype InternalLink = {\n\telement: HTMLAnchorElement\n\tlistener: EventListener\n}\n\nlet links: InternalLink[] = []\n\nconst navigate: EventListener = function (\n\tthis: { href: string },\n\tevent: Event,\n) {\n\tevent.preventDefault()\n\tmaybeRouter?.push(this.href)\n}\n\nconst addListeners = () => {\n\tconst node: HTMLElement | Comment | null =\n\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value\n\tif (node && \"querySelectorAll\" in node) {\n\t\t// Get all internal link tags and add listeners on them\n\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t.map((element) => {\n\t\t\t\tconst href = element.getAttribute(\"href\")\n\n\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\tconst listener = navigate.bind({ href })\n\t\t\t\t\telement.addEventListener(\"click\", listener)\n\n\t\t\t\t\treturn { element, listener }\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((link): link is InternalLink => link as boolean)\n\t}\n}\n\nconst removeListeners = () => {\n\tlinks.forEach(({ element, listener }) =>\n\t\telement.removeEventListener(\"click\", listener),\n\t)\n\tlinks = []\n}\n\nonMounted(() => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nwatch(html, () => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nonBeforeUnmount(() => {\n\tremoveListeners()\n})\n</script>\n\n<template>\n\t<component\n\t\tv-if=\"isFilled.richText(field) || fallback\"\n\t\tref=\"root\"\n\t\t:is=\"wrapper || defaultWrapper\"\n\t\tv-html=\"html\"\n\t/>\n</template>\n"],"names":["usePrismic","DEV","onMounted","devMsg","computed","isFilled","asHTML","ref","inject","routerKey","isInternalURL","nextTick","watch","onBeforeUnmount"],"mappings":";;;;;;;;AA0BA,MAAM,iBAAiB;;;;;;;;;;;;AAEvB,UAAM,QAAQ;AAQR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAE/B,QAAIC,YAAK;AACRC,UAAAA,UAAU,MAAM;AACP,gBAAA;AAAA,UACP,sPAAsPC,OAAA;AAAA,YACrP;AAAA,UAAA,CACA;AAAA,QACF;AAAA,MAAA,CACA;AAAA,IAAA;AAGI,UAAA,OAAOC,IAAAA,SAAS,MAAM;AAC3B,UAAI,CAACC,OAAAA,SAAS,SAAS,MAAM,KAAK,GAAG;AACpC,eAAO,MAAM,YAAY;AAAA,MAAA;AAGpB,YAAA,eAAe,MAAM,gBAAgB,QAAQ;AAC7C,YAAA,aAAa,MAAM,cAAc,QAAQ;AAE/C,aAAOC,OAAAA,OAAO,MAAM,OAAO,EAAE,cAAc,YAAY;AAAA,IAAA,CACvD;AAGK,UAAA,OAAOC,QAA8C,IAAI;AAEzD,UAAA,cAAcC,IAAAA,OAAOC,UAAA,WAAW,IAAI;AAO1C,QAAI,QAAwB,CAAC;AAEvB,UAAA,WAA0B,SAE/B,OACC;AACD,YAAM,eAAe;AACR,iDAAA,KAAK,KAAK;AAAA,IACxB;AAEA,UAAM,eAAe,MAAM;AACpB,YAAA,OACL,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;AACvD,UAAA,QAAQ,sBAAsB,MAAM;AAE/B,gBAAA,MAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC,EAC3C,IAAI,CAAC,YAAY;AACX,gBAAA,OAAO,QAAQ,aAAa,MAAM;AAEpC,cAAA,QAAQC,4BAAc,IAAI,GAAG;AAChC,kBAAM,WAAW,SAAS,KAAK,EAAE,MAAM;AAC/B,oBAAA,iBAAiB,SAAS,QAAQ;AAEnC,mBAAA,EAAE,SAAS,SAAS;AAAA,UAAA,OACrB;AACC,mBAAA;AAAA,UAAA;AAAA,QAER,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,MAAA;AAAA,IAE1D;AAEA,UAAM,kBAAkB,MAAM;AACvB,YAAA;AAAA,QAAQ,CAAC,EAAE,SAAS,SAAA,MACzB,QAAQ,oBAAoB,SAAS,QAAQ;AAAA,MAC9C;AACA,cAAQ,CAAC;AAAA,IACV;AAEAR,QAAAA,UAAU,MAAM;AACC,sBAAA;AAChBS,UAAAA,SAAS,YAAY;AAAA,IAAA,CACrB;AAEDC,QAAA,MAAM,MAAM,MAAM;AACD,sBAAA;AAChBD,UAAAA,SAAS,YAAY;AAAA,IAAA,CACrB;AAEDE,QAAAA,gBAAgB,MAAM;AACL,sBAAA;AAAA,IAAA,CAChB;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DeprecatedPrismicRichText.vue.cjs","sources":["../../src/PrismicRichText/DeprecatedPrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n// TODO: Remove in v6\nimport { asHTML, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport type { Component, PropType } from \"vue\"\nimport {\n\tcomputed,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\twatch,\n} from \"vue\"\nimport { routerKey } from \"vue-router\"\n\nimport { devMsg } from \"../lib/devMsg\"\nimport { isInternalURL } from \"../lib/isInternalURL\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport type { PrismicRichTextProps } from \"./PrismicRichText.vue\"\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\"\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tfallback: {\n\t\ttype: String as PropType<string>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tserializer: {\n\t\ttype: [Object, Function] as PropType<PrismicRichTextProps[\"serializer\"]>,\n\t},\n\twrapper: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"wrapper\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"DeprecatedPrismicRichText\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\tonMounted(() => {\n\t\tconsole.warn(\n\t\t\t`[PrismicRichText] You're using the deprecated version of \\`<PrismicRichText>\\` because either the \\`serializer\\` prop or the plugin \\`richTextSerializer\\` option were provided. This API will be removed in a future major. For more details, see ${devMsg(\n\t\t\t\t\"html-serialization-is-deprecated-with-prismic-rich-text\",\n\t\t\t)}`,\n\t\t)\n\t})\n}\n\nconst html = computed(() => {\n\tif (!isFilled.richText(props.field)) {\n\t\treturn props.fallback ?? \"\"\n\t}\n\n\tconst linkResolver = props.linkResolver ?? options.linkResolver\n\tconst serializer = props.serializer ?? options.richTextSerializer\n\n\treturn asHTML(props.field, { linkResolver, serializer })\n})\n\n// Internal links handling\nconst root = ref<HTMLElement | Comment | Component | null>(null)\n\nconst maybeRouter = inject(routerKey, null)\n\ntype InternalLink = {\n\telement: HTMLAnchorElement\n\tlistener: EventListener\n}\n\nlet links: InternalLink[] = []\n\nconst navigate: EventListener = function (\n\tthis: { href: string },\n\tevent: Event,\n) {\n\tevent.preventDefault()\n\tmaybeRouter?.push(this.href)\n}\n\nconst addListeners = () => {\n\tconst node: HTMLElement | Comment | null =\n\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value\n\tif (node && \"querySelectorAll\" in node) {\n\t\t// Get all internal link tags and add listeners on them\n\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t.map((element) => {\n\t\t\t\tconst href = element.getAttribute(\"href\")\n\n\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\tconst listener = navigate.bind({ href })\n\t\t\t\t\telement.addEventListener(\"click\", listener)\n\n\t\t\t\t\treturn { element, listener }\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((link): link is InternalLink => link as boolean)\n\t}\n}\n\nconst removeListeners = () => {\n\tlinks.forEach(({ element, listener }) =>\n\t\telement.removeEventListener(\"click\", listener),\n\t)\n\tlinks = []\n}\n\nonMounted(() => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nwatch(html, () => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nonBeforeUnmount(() => {\n\tremoveListeners()\n})\n</script>\n\n<template>\n\t<component\n\t\tv-if=\"isFilled.richText(field) || fallback\"\n\t\tref=\"root\"\n\t\t:is=\"wrapper || defaultWrapper\"\n\t\tv-html=\"html\"\n\t/>\n</template>\n"],"names":["usePrismic","DEV","onMounted","devMsg","computed","isFilled","asHTML","ref","inject","routerKey","isInternalURL","nextTick","watch","onBeforeUnmount"],"mappings":";;;;;;;;AA0BA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;AAIvB,UAAM,QAAQ;AAqBR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAE/B,QAAIC,YAAK;AACRC,UAAAA,UAAU,MAAM;AACP,gBAAA;AAAA,UACP,sPAAsPC,OAAA;AAAA,YACrP;AAAA,UAAA,CACA;AAAA,QACF;AAAA,MAAA,CACA;AAAA,IAAA;AAGI,UAAA,OAAOC,IAAAA,SAAS,MAAM;AAC3B,UAAI,CAACC,OAAAA,SAAS,SAAS,MAAM,KAAK,GAAG;AACpC,eAAO,MAAM,YAAY;AAAA,MAAA;AAGpB,YAAA,eAAe,MAAM,gBAAgB,QAAQ;AAC7C,YAAA,aAAa,MAAM,cAAc,QAAQ;AAE/C,aAAOC,OAAAA,OAAO,MAAM,OAAO,EAAE,cAAc,YAAY;AAAA,IAAA,CACvD;AAGK,UAAA,OAAOC,QAA8C,IAAI;AAEzD,UAAA,cAAcC,IAAAA,OAAOC,UAAA,WAAW,IAAI;AAO1C,QAAI,QAAwB,CAAC;AAEvB,UAAA,WAA0B,SAE/B,OACC;AACD,YAAM,eAAe;AACR,iDAAA,KAAK,KAAK;AAAA,IACxB;AAEA,UAAM,eAAe,MAAM;AACpB,YAAA,OACL,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;AACvD,UAAA,QAAQ,sBAAsB,MAAM;AAE/B,gBAAA,MAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC,EAC3C,IAAI,CAAC,YAAY;AACX,gBAAA,OAAO,QAAQ,aAAa,MAAM;AAEpC,cAAA,QAAQC,4BAAc,IAAI,GAAG;AAChC,kBAAM,WAAW,SAAS,KAAK,EAAE,MAAM;AAC/B,oBAAA,iBAAiB,SAAS,QAAQ;AAEnC,mBAAA,EAAE,SAAS,SAAS;AAAA,UAAA,OACrB;AACC,mBAAA;AAAA,UAAA;AAAA,QAER,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,MAAA;AAAA,IAE1D;AAEA,UAAM,kBAAkB,MAAM;AACvB,YAAA;AAAA,QAAQ,CAAC,EAAE,SAAS,SAAA,MACzB,QAAQ,oBAAoB,SAAS,QAAQ;AAAA,MAC9C;AACA,cAAQ,CAAC;AAAA,IACV;AAEAR,QAAAA,UAAU,MAAM;AACC,sBAAA;AAChBS,UAAAA,SAAS,YAAY;AAAA,IAAA,CACrB;AAEDC,QAAA,MAAM,MAAM,MAAM;AACD,sBAAA;AAChBD,UAAAA,SAAS,YAAY;AAAA,IAAA,CACrB;AAEDE,QAAAA,gBAAgB,MAAM;AACL,sBAAA;AAAA,IAAA,CAChB;;;;;;;;;;;;"}
@@ -1,8 +1,38 @@
1
+ import { PropType } from 'vue';
1
2
  import { PrismicRichTextProps } from './PrismicRichText.vue';
2
- type __VLS_Props = Pick<PrismicRichTextProps, "field" | "linkResolver" | "serializer" | "wrapper"> & {
3
- fallback?: string;
4
- };
5
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
3
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
+ field: {
5
+ type: PropType<PrismicRichTextProps["field"]>;
6
+ };
7
+ fallback: {
8
+ type: PropType<string>;
9
+ };
10
+ linkResolver: {
11
+ type: PropType<PrismicRichTextProps["linkResolver"]>;
12
+ };
13
+ serializer: {
14
+ type: PropType<PrismicRichTextProps["serializer"]>;
15
+ };
16
+ wrapper: {
17
+ type: PropType<PrismicRichTextProps["wrapper"]>;
18
+ };
19
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
20
+ field: {
21
+ type: PropType<PrismicRichTextProps["field"]>;
22
+ };
23
+ fallback: {
24
+ type: PropType<string>;
25
+ };
26
+ linkResolver: {
27
+ type: PropType<PrismicRichTextProps["linkResolver"]>;
28
+ };
29
+ serializer: {
30
+ type: PropType<PrismicRichTextProps["serializer"]>;
31
+ };
32
+ wrapper: {
33
+ type: PropType<PrismicRichTextProps["wrapper"]>;
34
+ };
35
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
6
36
  root: unknown;
7
37
  }, any>;
8
38
  export default _default;
@@ -1,4 +1,4 @@
1
- import { defineComponent, onMounted, computed, ref, inject, nextTick, watch, onBeforeUnmount, unref, openBlock, createBlock, resolveDynamicComponent, createCommentVNode } from "vue";
1
+ import { defineComponent, onMounted, computed, ref, inject, nextTick, watch, onBeforeUnmount, createBlock, createCommentVNode, unref, openBlock, resolveDynamicComponent } from "vue";
2
2
  import { isFilled, asHTML } from "@prismicio/client";
3
3
  import { DEV } from "esm-env";
4
4
  import { routerKey } from "vue-router";
@@ -10,11 +10,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10
10
  ...{ name: "DeprecatedPrismicRichText" },
11
11
  __name: "DeprecatedPrismicRichText",
12
12
  props: {
13
- field: {},
14
- linkResolver: {},
15
- serializer: { type: Function },
16
- wrapper: {},
17
- fallback: {}
13
+ field: {
14
+ type: Array
15
+ },
16
+ fallback: {
17
+ type: String
18
+ },
19
+ linkResolver: {
20
+ type: Function
21
+ },
22
+ serializer: {
23
+ type: [Object, Function]
24
+ },
25
+ wrapper: {
26
+ type: [String, Object, Function]
27
+ }
18
28
  },
19
29
  setup(__props) {
20
30
  const props = __props;
@@ -76,7 +86,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
76
86
  removeListeners();
77
87
  });
78
88
  return (_ctx, _cache) => {
79
- return unref(isFilled).richText(_ctx.field) || _ctx.fallback ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.wrapper || defaultWrapper), {
89
+ return unref(isFilled).richText(__props.field) || __props.fallback ? (openBlock(), createBlock(resolveDynamicComponent(__props.wrapper || defaultWrapper), {
80
90
  key: 0,
81
91
  ref_key: "root",
82
92
  ref: root,
@@ -1 +1 @@
1
- {"version":3,"file":"DeprecatedPrismicRichText.vue.js","sources":["../../src/PrismicRichText/DeprecatedPrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n// TODO: Remove in v6\nimport { asHTML, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport type { Component } from \"vue\"\nimport {\n\tcomputed,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\twatch,\n} from \"vue\"\nimport { routerKey } from \"vue-router\"\n\nimport { devMsg } from \"../lib/devMsg\"\nimport { isInternalURL } from \"../lib/isInternalURL\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport type { PrismicRichTextProps } from \"./PrismicRichText.vue\"\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\"\n\nconst props = defineProps<\n\tPick<\n\t\tPrismicRichTextProps,\n\t\t\"field\" | \"linkResolver\" | \"serializer\" | \"wrapper\"\n\t> & { fallback?: string }\n>()\ndefineOptions({ name: \"DeprecatedPrismicRichText\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\tonMounted(() => {\n\t\tconsole.warn(\n\t\t\t`[PrismicRichText] You're using the deprecated version of \\`<PrismicRichText>\\` because either the \\`serializer\\` prop or the plugin \\`richTextSerializer\\` option were provided. This API will be removed in a future major. For more details, see ${devMsg(\n\t\t\t\t\"html-serialization-is-deprecated-with-prismic-rich-text\",\n\t\t\t)}`,\n\t\t)\n\t})\n}\n\nconst html = computed(() => {\n\tif (!isFilled.richText(props.field)) {\n\t\treturn props.fallback ?? \"\"\n\t}\n\n\tconst linkResolver = props.linkResolver ?? options.linkResolver\n\tconst serializer = props.serializer ?? options.richTextSerializer\n\n\treturn asHTML(props.field, { linkResolver, serializer })\n})\n\n// Internal links handling\nconst root = ref<HTMLElement | Comment | Component | null>(null)\n\nconst maybeRouter = inject(routerKey, null)\n\ntype InternalLink = {\n\telement: HTMLAnchorElement\n\tlistener: EventListener\n}\n\nlet links: InternalLink[] = []\n\nconst navigate: EventListener = function (\n\tthis: { href: string },\n\tevent: Event,\n) {\n\tevent.preventDefault()\n\tmaybeRouter?.push(this.href)\n}\n\nconst addListeners = () => {\n\tconst node: HTMLElement | Comment | null =\n\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value\n\tif (node && \"querySelectorAll\" in node) {\n\t\t// Get all internal link tags and add listeners on them\n\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t.map((element) => {\n\t\t\t\tconst href = element.getAttribute(\"href\")\n\n\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\tconst listener = navigate.bind({ href })\n\t\t\t\t\telement.addEventListener(\"click\", listener)\n\n\t\t\t\t\treturn { element, listener }\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((link): link is InternalLink => link as boolean)\n\t}\n}\n\nconst removeListeners = () => {\n\tlinks.forEach(({ element, listener }) =>\n\t\telement.removeEventListener(\"click\", listener),\n\t)\n\tlinks = []\n}\n\nonMounted(() => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nwatch(html, () => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nonBeforeUnmount(() => {\n\tremoveListeners()\n})\n</script>\n\n<template>\n\t<component\n\t\tv-if=\"isFilled.richText(field) || fallback\"\n\t\tref=\"root\"\n\t\t:is=\"wrapper || defaultWrapper\"\n\t\tv-html=\"html\"\n\t/>\n</template>\n"],"names":[],"mappings":";;;;;;;AA0BA,MAAM,iBAAiB;;;;;;;;;;;;AAEvB,UAAM,QAAQ;AAQR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAE/B,QAAI,KAAK;AACR,gBAAU,MAAM;AACP,gBAAA;AAAA,UACP,sPAAsP;AAAA,YACrP;AAAA,UAAA,CACA;AAAA,QACF;AAAA,MAAA,CACA;AAAA,IAAA;AAGI,UAAA,OAAO,SAAS,MAAM;AAC3B,UAAI,CAAC,SAAS,SAAS,MAAM,KAAK,GAAG;AACpC,eAAO,MAAM,YAAY;AAAA,MAAA;AAGpB,YAAA,eAAe,MAAM,gBAAgB,QAAQ;AAC7C,YAAA,aAAa,MAAM,cAAc,QAAQ;AAE/C,aAAO,OAAO,MAAM,OAAO,EAAE,cAAc,YAAY;AAAA,IAAA,CACvD;AAGK,UAAA,OAAO,IAA8C,IAAI;AAEzD,UAAA,cAAc,OAAO,WAAW,IAAI;AAO1C,QAAI,QAAwB,CAAC;AAEvB,UAAA,WAA0B,SAE/B,OACC;AACD,YAAM,eAAe;AACR,iDAAA,KAAK,KAAK;AAAA,IACxB;AAEA,UAAM,eAAe,MAAM;AACpB,YAAA,OACL,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;AACvD,UAAA,QAAQ,sBAAsB,MAAM;AAE/B,gBAAA,MAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC,EAC3C,IAAI,CAAC,YAAY;AACX,gBAAA,OAAO,QAAQ,aAAa,MAAM;AAEpC,cAAA,QAAQ,cAAc,IAAI,GAAG;AAChC,kBAAM,WAAW,SAAS,KAAK,EAAE,MAAM;AAC/B,oBAAA,iBAAiB,SAAS,QAAQ;AAEnC,mBAAA,EAAE,SAAS,SAAS;AAAA,UAAA,OACrB;AACC,mBAAA;AAAA,UAAA;AAAA,QAER,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,MAAA;AAAA,IAE1D;AAEA,UAAM,kBAAkB,MAAM;AACvB,YAAA;AAAA,QAAQ,CAAC,EAAE,SAAS,SAAA,MACzB,QAAQ,oBAAoB,SAAS,QAAQ;AAAA,MAC9C;AACA,cAAQ,CAAC;AAAA,IACV;AAEA,cAAU,MAAM;AACC,sBAAA;AAChB,eAAS,YAAY;AAAA,IAAA,CACrB;AAED,UAAM,MAAM,MAAM;AACD,sBAAA;AAChB,eAAS,YAAY;AAAA,IAAA,CACrB;AAED,oBAAgB,MAAM;AACL,sBAAA;AAAA,IAAA,CAChB;;;;;;;;;;;"}
1
+ {"version":3,"file":"DeprecatedPrismicRichText.vue.js","sources":["../../src/PrismicRichText/DeprecatedPrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n// TODO: Remove in v6\nimport { asHTML, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport type { Component, PropType } from \"vue\"\nimport {\n\tcomputed,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\twatch,\n} from \"vue\"\nimport { routerKey } from \"vue-router\"\n\nimport { devMsg } from \"../lib/devMsg\"\nimport { isInternalURL } from \"../lib/isInternalURL\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport type { PrismicRichTextProps } from \"./PrismicRichText.vue\"\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\"\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tfallback: {\n\t\ttype: String as PropType<string>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tserializer: {\n\t\ttype: [Object, Function] as PropType<PrismicRichTextProps[\"serializer\"]>,\n\t},\n\twrapper: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"wrapper\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"DeprecatedPrismicRichText\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\tonMounted(() => {\n\t\tconsole.warn(\n\t\t\t`[PrismicRichText] You're using the deprecated version of \\`<PrismicRichText>\\` because either the \\`serializer\\` prop or the plugin \\`richTextSerializer\\` option were provided. This API will be removed in a future major. For more details, see ${devMsg(\n\t\t\t\t\"html-serialization-is-deprecated-with-prismic-rich-text\",\n\t\t\t)}`,\n\t\t)\n\t})\n}\n\nconst html = computed(() => {\n\tif (!isFilled.richText(props.field)) {\n\t\treturn props.fallback ?? \"\"\n\t}\n\n\tconst linkResolver = props.linkResolver ?? options.linkResolver\n\tconst serializer = props.serializer ?? options.richTextSerializer\n\n\treturn asHTML(props.field, { linkResolver, serializer })\n})\n\n// Internal links handling\nconst root = ref<HTMLElement | Comment | Component | null>(null)\n\nconst maybeRouter = inject(routerKey, null)\n\ntype InternalLink = {\n\telement: HTMLAnchorElement\n\tlistener: EventListener\n}\n\nlet links: InternalLink[] = []\n\nconst navigate: EventListener = function (\n\tthis: { href: string },\n\tevent: Event,\n) {\n\tevent.preventDefault()\n\tmaybeRouter?.push(this.href)\n}\n\nconst addListeners = () => {\n\tconst node: HTMLElement | Comment | null =\n\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value\n\tif (node && \"querySelectorAll\" in node) {\n\t\t// Get all internal link tags and add listeners on them\n\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t.map((element) => {\n\t\t\t\tconst href = element.getAttribute(\"href\")\n\n\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\tconst listener = navigate.bind({ href })\n\t\t\t\t\telement.addEventListener(\"click\", listener)\n\n\t\t\t\t\treturn { element, listener }\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((link): link is InternalLink => link as boolean)\n\t}\n}\n\nconst removeListeners = () => {\n\tlinks.forEach(({ element, listener }) =>\n\t\telement.removeEventListener(\"click\", listener),\n\t)\n\tlinks = []\n}\n\nonMounted(() => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nwatch(html, () => {\n\tremoveListeners()\n\tnextTick(addListeners)\n})\n\nonBeforeUnmount(() => {\n\tremoveListeners()\n})\n</script>\n\n<template>\n\t<component\n\t\tv-if=\"isFilled.richText(field) || fallback\"\n\t\tref=\"root\"\n\t\t:is=\"wrapper || defaultWrapper\"\n\t\tv-html=\"html\"\n\t/>\n</template>\n"],"names":[],"mappings":";;;;;;;AA0BA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;AAIvB,UAAM,QAAQ;AAqBR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAE/B,QAAI,KAAK;AACR,gBAAU,MAAM;AACP,gBAAA;AAAA,UACP,sPAAsP;AAAA,YACrP;AAAA,UAAA,CACA;AAAA,QACF;AAAA,MAAA,CACA;AAAA,IAAA;AAGI,UAAA,OAAO,SAAS,MAAM;AAC3B,UAAI,CAAC,SAAS,SAAS,MAAM,KAAK,GAAG;AACpC,eAAO,MAAM,YAAY;AAAA,MAAA;AAGpB,YAAA,eAAe,MAAM,gBAAgB,QAAQ;AAC7C,YAAA,aAAa,MAAM,cAAc,QAAQ;AAE/C,aAAO,OAAO,MAAM,OAAO,EAAE,cAAc,YAAY;AAAA,IAAA,CACvD;AAGK,UAAA,OAAO,IAA8C,IAAI;AAEzD,UAAA,cAAc,OAAO,WAAW,IAAI;AAO1C,QAAI,QAAwB,CAAC;AAEvB,UAAA,WAA0B,SAE/B,OACC;AACD,YAAM,eAAe;AACR,iDAAA,KAAK,KAAK;AAAA,IACxB;AAEA,UAAM,eAAe,MAAM;AACpB,YAAA,OACL,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;AACvD,UAAA,QAAQ,sBAAsB,MAAM;AAE/B,gBAAA,MAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC,EAC3C,IAAI,CAAC,YAAY;AACX,gBAAA,OAAO,QAAQ,aAAa,MAAM;AAEpC,cAAA,QAAQ,cAAc,IAAI,GAAG;AAChC,kBAAM,WAAW,SAAS,KAAK,EAAE,MAAM;AAC/B,oBAAA,iBAAiB,SAAS,QAAQ;AAEnC,mBAAA,EAAE,SAAS,SAAS;AAAA,UAAA,OACrB;AACC,mBAAA;AAAA,UAAA;AAAA,QAER,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,MAAA;AAAA,IAE1D;AAEA,UAAM,kBAAkB,MAAM;AACvB,YAAA;AAAA,QAAQ,CAAC,EAAE,SAAS,SAAA,MACzB,QAAQ,oBAAoB,SAAS,QAAQ;AAAA,MAC9C;AACA,cAAQ,CAAC;AAAA,IACV;AAEA,cAAU,MAAM;AACC,sBAAA;AAChB,eAAS,YAAY;AAAA,IAAA,CACrB;AAED,UAAM,MAAM,MAAM;AACD,sBAAA;AAChB,eAAS,YAAY;AAAA,IAAA,CACrB;AAED,oBAAgB,MAAM;AACL,sBAAA;AAAA,IAAA,CAChB;;;;;;;;;;;"}
@@ -11,12 +11,24 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
11
11
  ...{ name: "PrismicRichText" },
12
12
  __name: "PrismicRichText",
13
13
  props: {
14
- field: {},
15
- fallback: {},
16
- components: {},
17
- linkResolver: {},
18
- serializer: { type: Function },
19
- wrapper: {}
14
+ field: {
15
+ type: Array
16
+ },
17
+ fallback: {
18
+ type: [String, Object, Function]
19
+ },
20
+ components: {
21
+ type: Object
22
+ },
23
+ linkResolver: {
24
+ type: Function
25
+ },
26
+ serializer: {
27
+ type: [Object, Function]
28
+ },
29
+ wrapper: {
30
+ type: [String, Object, Function]
31
+ }
20
32
  },
21
33
  setup(__props) {
22
34
  const props = __props;
@@ -57,9 +69,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
57
69
  });
58
70
  }
59
71
  return (_ctx, _cache) => {
60
- return isModern.value && (vue.unref(client.isFilled).richText(_ctx.field) || _ctx.fallback) ? (vue.openBlock(), vue.createBlock(Wrapper_vue_vue_type_script_setup_true_lang, {
72
+ return isModern.value && (vue.unref(client.isFilled).richText(__props.field) || __props.fallback) ? (vue.openBlock(), vue.createBlock(Wrapper_vue_vue_type_script_setup_true_lang, {
61
73
  key: 0,
62
- wrapper: _ctx.wrapper
74
+ wrapper: __props.wrapper
63
75
  }, {
64
76
  default: vue.withCtx(() => [
65
77
  children.value.length ? (vue.openBlock(), vue.createBlock(PrismicRichTextSerialize_vue_vue_type_script_setup_true_lang, {
@@ -67,16 +79,16 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
67
79
  children: children.value,
68
80
  components: resolvedComponents.value,
69
81
  "link-resolver": resolvedLinkResolver.value
70
- }, null, 8, ["children", "components", "link-resolver"])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.fallback), { key: 1 }))
82
+ }, null, 8, ["children", "components", "link-resolver"])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(__props.fallback), { key: 1 }))
71
83
  ]),
72
84
  _: 1
73
85
  }, 8, ["wrapper"])) : !isModern.value ? (vue.openBlock(), vue.createBlock(DeprecatedPrismicRichText_vue_vue_type_script_setup_true_lang, {
74
86
  key: 1,
75
- field: _ctx.field,
76
- fallback: typeof _ctx.fallback === "string" ? _ctx.fallback : void 0,
77
- "link-resolver": _ctx.linkResolver,
78
- serializer: _ctx.serializer,
79
- wrapper: _ctx.wrapper
87
+ field: __props.field,
88
+ fallback: typeof __props.fallback === "string" ? __props.fallback : void 0,
89
+ "link-resolver": __props.linkResolver,
90
+ serializer: __props.serializer,
91
+ wrapper: __props.wrapper
80
92
  }, null, 8, ["field", "fallback", "link-resolver", "serializer", "wrapper"])) : vue.createCommentVNode("", true);
81
93
  };
82
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.vue.cjs","sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n\ttype HTMLRichTextFunctionSerializer,\n\ttype HTMLRichTextMapSerializer,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport Wrapper from \"../lib/Wrapper.vue\"\n\nimport type { ComponentOrTagName } from \"../types\"\nimport type { VueRichTextSerializer } from \"./types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport DeprecatedPrismicRichText from \"./DeprecatedPrismicRichText.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `components` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\t// TODO: Remove in v6\n\tserializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer\n\n\t/**\n\t * An HTML tag name or a component used to wrap the output. `<PrismicText />`\n\t * is not wrapped by default.\n\t *\n\t * @defaultValue `\"template\"` (no wrapper)\n\t */\n\twrapper?: ComponentOrTagName\n}\n\nconst props = defineProps<PrismicRichTextProps>()\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { options } = usePrismic()\n\nconst resolvedComponents = computed(() => {\n\treturn props.components || options.components?.richTextComponents\n})\n\nconst resolvedLinkResolver = computed(() => {\n\treturn props.linkResolver || options.linkResolver\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nconst isModern = computed(() => {\n\t// Explicit components prop\n\tif (props.components) {\n\t\treturn true\n\t}\n\n\t// Explicit serializer prop\n\tif (props.serializer) {\n\t\treturn false\n\t}\n\n\t// Global components option\n\tif (options.components?.richTextComponents) {\n\t\treturn true\n\t}\n\n\t// Global serializer option\n\tif (options.richTextSerializer) {\n\t\treturn false\n\t}\n\n\t// Default to modern\n\treturn true\n})\n\nif (DEV) {\n\twatchEffect(() => {\n\t\t// TODO: Remove in v6\n\t\tif (props.components && props.serializer) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] Only one of \"components\" or \"serializer\" (deprecated) props can be provided. You can resolve this warning by removing either the \"components\" or \"serializer\" prop. \"components\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n</script>\n\n<template>\n\t<Wrapper\n\t\tv-if=\"isModern && (isFilled.richText(field) || fallback)\"\n\t\t:wrapper=\"wrapper\"\n\t>\n\t\t<PrismicRichTextSerialize\n\t\t\tv-if=\"children.length\"\n\t\t\t:children=\"children\"\n\t\t\t:components=\"resolvedComponents\"\n\t\t\t:link-resolver=\"resolvedLinkResolver\"\n\t\t/>\n\t\t<component v-else :is=\"fallback\" />\n\t</Wrapper>\n\t<DeprecatedPrismicRichText\n\t\tv-else-if=\"!isModern\"\n\t\t:field=\"field\"\n\t\t:fallback=\"typeof fallback === 'string' ? fallback : undefined\"\n\t\t:link-resolver=\"linkResolver\"\n\t\t:serializer=\"serializer\"\n\t\t:wrapper=\"wrapper\"\n\t/>\n</template>\n"],"names":["usePrismic","computed","asTree","DEV","watchEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiFA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAEzB,UAAA,qBAAqBC,IAAAA,SAAS,MAAM;;AAClC,aAAA,MAAM,gBAAc,aAAQ,eAAR,mBAAoB;AAAA,IAAA,CAC/C;AAEK,UAAA,uBAAuBA,IAAAA,SAAS,MAAM;AACpC,aAAA,MAAM,gBAAgB,QAAQ;AAAA,IAAA,CACrC;AAEK,UAAA,WAAWA,IAAAA,SAAS,MAAM;AAC/B,aAAOC,SAAO,OAAA,MAAM,SAAS,CAAA,CAAE,EAAE;AAAA,IAAA,CACjC;AAEK,UAAA,WAAWD,IAAAA,SAAS,MAAM;;AAE/B,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIR,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIJ,WAAA,aAAQ,eAAR,mBAAoB,oBAAoB;AACpC,eAAA;AAAA,MAAA;AAIR,UAAI,QAAQ,oBAAoB;AACxB,eAAA;AAAA,MAAA;AAID,aAAA;AAAA,IAAA,CACP;AAED,QAAIE,YAAK;AACRC,UAAAA,YAAY,MAAM;AAEb,YAAA,MAAM,cAAc,MAAM,YAAY;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"PrismicRichText.vue.cjs","sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n\ttype HTMLRichTextFunctionSerializer,\n\ttype HTMLRichTextMapSerializer,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport { DEV } from \"esm-env\"\nimport type { PropType } from \"vue\"\nimport { computed, watchEffect } from \"vue\"\n\nimport Wrapper from \"../lib/Wrapper.vue\"\n\nimport type { ComponentOrTagName } from \"../types\"\nimport type { VueRichTextSerializer } from \"./types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport DeprecatedPrismicRichText from \"./DeprecatedPrismicRichText.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `components` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\t// TODO: Remove in v6\n\tserializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer\n\n\t/**\n\t * An HTML tag name or a component used to wrap the output. `<PrismicText />`\n\t * is not wrapped by default.\n\t *\n\t * @defaultValue `\"template\"` (no wrapper)\n\t */\n\twrapper?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tserializer: {\n\t\ttype: [Object, Function] as PropType<PrismicRichTextProps[\"serializer\"]>,\n\t},\n\twrapper: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"wrapper\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { options } = usePrismic()\n\nconst resolvedComponents = computed(() => {\n\treturn props.components || options.components?.richTextComponents\n})\n\nconst resolvedLinkResolver = computed(() => {\n\treturn props.linkResolver || options.linkResolver\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nconst isModern = computed(() => {\n\t// Explicit components prop\n\tif (props.components) {\n\t\treturn true\n\t}\n\n\t// Explicit serializer prop\n\tif (props.serializer) {\n\t\treturn false\n\t}\n\n\t// Global components option\n\tif (options.components?.richTextComponents) {\n\t\treturn true\n\t}\n\n\t// Global serializer option\n\tif (options.richTextSerializer) {\n\t\treturn false\n\t}\n\n\t// Default to modern\n\treturn true\n})\n\nif (DEV) {\n\twatchEffect(() => {\n\t\t// TODO: Remove in v6\n\t\tif (props.components && props.serializer) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] Only one of \"components\" or \"serializer\" (deprecated) props can be provided. You can resolve this warning by removing either the \"components\" or \"serializer\" prop. \"components\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n</script>\n\n<template>\n\t<Wrapper\n\t\tv-if=\"isModern && (isFilled.richText(field) || fallback)\"\n\t\t:wrapper=\"wrapper\"\n\t>\n\t\t<PrismicRichTextSerialize\n\t\t\tv-if=\"children.length\"\n\t\t\t:children=\"children\"\n\t\t\t:components=\"resolvedComponents\"\n\t\t\t:link-resolver=\"resolvedLinkResolver\"\n\t\t/>\n\t\t<component v-else :is=\"fallback\" />\n\t</Wrapper>\n\t<DeprecatedPrismicRichText\n\t\tv-else-if=\"!isModern\"\n\t\t:field=\"field\"\n\t\t:fallback=\"typeof fallback === 'string' ? fallback : undefined\"\n\t\t:link-resolver=\"linkResolver\"\n\t\t:serializer=\"serializer\"\n\t\t:wrapper=\"wrapper\"\n\t/>\n</template>\n"],"names":["usePrismic","computed","asTree","DEV","watchEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,UAAM,QAAQ;AA0BR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAEzB,UAAA,qBAAqBC,IAAAA,SAAS,MAAM;;AAClC,aAAA,MAAM,gBAAc,aAAQ,eAAR,mBAAoB;AAAA,IAAA,CAC/C;AAEK,UAAA,uBAAuBA,IAAAA,SAAS,MAAM;AACpC,aAAA,MAAM,gBAAgB,QAAQ;AAAA,IAAA,CACrC;AAEK,UAAA,WAAWA,IAAAA,SAAS,MAAM;AAC/B,aAAOC,SAAO,OAAA,MAAM,SAAS,CAAA,CAAE,EAAE;AAAA,IAAA,CACjC;AAEK,UAAA,WAAWD,IAAAA,SAAS,MAAM;;AAE/B,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIR,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIJ,WAAA,aAAQ,eAAR,mBAAoB,oBAAoB;AACpC,eAAA;AAAA,MAAA;AAIR,UAAI,QAAQ,oBAAoB;AACxB,eAAA;AAAA,MAAA;AAID,aAAA;AAAA,IAAA,CACP;AAED,QAAIE,YAAK;AACRC,UAAAA,YAAY,MAAM;AAEb,YAAA,MAAM,cAAc,MAAM,YAAY;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { HTMLRichTextFunctionSerializer, HTMLRichTextMapSerializer, LinkResolverFunction, RichTextField } from '@prismicio/client';
2
+ import { PropType } from 'vue';
2
3
  import { ComponentOrTagName } from '../types';
3
4
  import { VueRichTextSerializer } from './types';
4
5
  /**
@@ -53,5 +54,43 @@ export type PrismicRichTextProps = {
53
54
  */
54
55
  wrapper?: ComponentOrTagName;
55
56
  };
56
- declare const _default: import('vue').DefineComponent<PrismicRichTextProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<PrismicRichTextProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
57
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
58
+ field: {
59
+ type: PropType<PrismicRichTextProps["field"]>;
60
+ };
61
+ fallback: {
62
+ type: PropType<PrismicRichTextProps["fallback"]>;
63
+ };
64
+ components: {
65
+ type: PropType<PrismicRichTextProps["components"]>;
66
+ };
67
+ linkResolver: {
68
+ type: PropType<PrismicRichTextProps["linkResolver"]>;
69
+ };
70
+ serializer: {
71
+ type: PropType<PrismicRichTextProps["serializer"]>;
72
+ };
73
+ wrapper: {
74
+ type: PropType<PrismicRichTextProps["wrapper"]>;
75
+ };
76
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
77
+ field: {
78
+ type: PropType<PrismicRichTextProps["field"]>;
79
+ };
80
+ fallback: {
81
+ type: PropType<PrismicRichTextProps["fallback"]>;
82
+ };
83
+ components: {
84
+ type: PropType<PrismicRichTextProps["components"]>;
85
+ };
86
+ linkResolver: {
87
+ type: PropType<PrismicRichTextProps["linkResolver"]>;
88
+ };
89
+ serializer: {
90
+ type: PropType<PrismicRichTextProps["serializer"]>;
91
+ };
92
+ wrapper: {
93
+ type: PropType<PrismicRichTextProps["wrapper"]>;
94
+ };
95
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
57
96
  export default _default;
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, watchEffect, unref, openBlock, createBlock, withCtx, resolveDynamicComponent, createCommentVNode } from "vue";
1
+ import { defineComponent, computed, watchEffect, createBlock, createCommentVNode, unref, openBlock, withCtx, resolveDynamicComponent } from "vue";
2
2
  import { isFilled } from "@prismicio/client";
3
3
  import { asTree } from "@prismicio/client/richtext";
4
4
  import { DEV } from "esm-env";
@@ -10,12 +10,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10
10
  ...{ name: "PrismicRichText" },
11
11
  __name: "PrismicRichText",
12
12
  props: {
13
- field: {},
14
- fallback: {},
15
- components: {},
16
- linkResolver: {},
17
- serializer: { type: Function },
18
- wrapper: {}
13
+ field: {
14
+ type: Array
15
+ },
16
+ fallback: {
17
+ type: [String, Object, Function]
18
+ },
19
+ components: {
20
+ type: Object
21
+ },
22
+ linkResolver: {
23
+ type: Function
24
+ },
25
+ serializer: {
26
+ type: [Object, Function]
27
+ },
28
+ wrapper: {
29
+ type: [String, Object, Function]
30
+ }
19
31
  },
20
32
  setup(__props) {
21
33
  const props = __props;
@@ -56,9 +68,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
68
  });
57
69
  }
58
70
  return (_ctx, _cache) => {
59
- return isModern.value && (unref(isFilled).richText(_ctx.field) || _ctx.fallback) ? (openBlock(), createBlock(_sfc_main$1, {
71
+ return isModern.value && (unref(isFilled).richText(__props.field) || __props.fallback) ? (openBlock(), createBlock(_sfc_main$1, {
60
72
  key: 0,
61
- wrapper: _ctx.wrapper
73
+ wrapper: __props.wrapper
62
74
  }, {
63
75
  default: withCtx(() => [
64
76
  children.value.length ? (openBlock(), createBlock(_sfc_main$2, {
@@ -66,16 +78,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
66
78
  children: children.value,
67
79
  components: resolvedComponents.value,
68
80
  "link-resolver": resolvedLinkResolver.value
69
- }, null, 8, ["children", "components", "link-resolver"])) : (openBlock(), createBlock(resolveDynamicComponent(_ctx.fallback), { key: 1 }))
81
+ }, null, 8, ["children", "components", "link-resolver"])) : (openBlock(), createBlock(resolveDynamicComponent(__props.fallback), { key: 1 }))
70
82
  ]),
71
83
  _: 1
72
84
  }, 8, ["wrapper"])) : !isModern.value ? (openBlock(), createBlock(_sfc_main$3, {
73
85
  key: 1,
74
- field: _ctx.field,
75
- fallback: typeof _ctx.fallback === "string" ? _ctx.fallback : void 0,
76
- "link-resolver": _ctx.linkResolver,
77
- serializer: _ctx.serializer,
78
- wrapper: _ctx.wrapper
86
+ field: __props.field,
87
+ fallback: typeof __props.fallback === "string" ? __props.fallback : void 0,
88
+ "link-resolver": __props.linkResolver,
89
+ serializer: __props.serializer,
90
+ wrapper: __props.wrapper
79
91
  }, null, 8, ["field", "fallback", "link-resolver", "serializer", "wrapper"])) : createCommentVNode("", true);
80
92
  };
81
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.vue.js","sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n\ttype HTMLRichTextFunctionSerializer,\n\ttype HTMLRichTextMapSerializer,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport Wrapper from \"../lib/Wrapper.vue\"\n\nimport type { ComponentOrTagName } from \"../types\"\nimport type { VueRichTextSerializer } from \"./types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport DeprecatedPrismicRichText from \"./DeprecatedPrismicRichText.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `components` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\t// TODO: Remove in v6\n\tserializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer\n\n\t/**\n\t * An HTML tag name or a component used to wrap the output. `<PrismicText />`\n\t * is not wrapped by default.\n\t *\n\t * @defaultValue `\"template\"` (no wrapper)\n\t */\n\twrapper?: ComponentOrTagName\n}\n\nconst props = defineProps<PrismicRichTextProps>()\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { options } = usePrismic()\n\nconst resolvedComponents = computed(() => {\n\treturn props.components || options.components?.richTextComponents\n})\n\nconst resolvedLinkResolver = computed(() => {\n\treturn props.linkResolver || options.linkResolver\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nconst isModern = computed(() => {\n\t// Explicit components prop\n\tif (props.components) {\n\t\treturn true\n\t}\n\n\t// Explicit serializer prop\n\tif (props.serializer) {\n\t\treturn false\n\t}\n\n\t// Global components option\n\tif (options.components?.richTextComponents) {\n\t\treturn true\n\t}\n\n\t// Global serializer option\n\tif (options.richTextSerializer) {\n\t\treturn false\n\t}\n\n\t// Default to modern\n\treturn true\n})\n\nif (DEV) {\n\twatchEffect(() => {\n\t\t// TODO: Remove in v6\n\t\tif (props.components && props.serializer) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] Only one of \"components\" or \"serializer\" (deprecated) props can be provided. You can resolve this warning by removing either the \"components\" or \"serializer\" prop. \"components\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n</script>\n\n<template>\n\t<Wrapper\n\t\tv-if=\"isModern && (isFilled.richText(field) || fallback)\"\n\t\t:wrapper=\"wrapper\"\n\t>\n\t\t<PrismicRichTextSerialize\n\t\t\tv-if=\"children.length\"\n\t\t\t:children=\"children\"\n\t\t\t:components=\"resolvedComponents\"\n\t\t\t:link-resolver=\"resolvedLinkResolver\"\n\t\t/>\n\t\t<component v-else :is=\"fallback\" />\n\t</Wrapper>\n\t<DeprecatedPrismicRichText\n\t\tv-else-if=\"!isModern\"\n\t\t:field=\"field\"\n\t\t:fallback=\"typeof fallback === 'string' ? fallback : undefined\"\n\t\t:link-resolver=\"linkResolver\"\n\t\t:serializer=\"serializer\"\n\t\t:wrapper=\"wrapper\"\n\t/>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAiFA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAEzB,UAAA,qBAAqB,SAAS,MAAM;;AAClC,aAAA,MAAM,gBAAc,aAAQ,eAAR,mBAAoB;AAAA,IAAA,CAC/C;AAEK,UAAA,uBAAuB,SAAS,MAAM;AACpC,aAAA,MAAM,gBAAgB,QAAQ;AAAA,IAAA,CACrC;AAEK,UAAA,WAAW,SAAS,MAAM;AAC/B,aAAO,OAAO,MAAM,SAAS,CAAA,CAAE,EAAE;AAAA,IAAA,CACjC;AAEK,UAAA,WAAW,SAAS,MAAM;;AAE/B,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIR,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIJ,WAAA,aAAQ,eAAR,mBAAoB,oBAAoB;AACpC,eAAA;AAAA,MAAA;AAIR,UAAI,QAAQ,oBAAoB;AACxB,eAAA;AAAA,MAAA;AAID,aAAA;AAAA,IAAA,CACP;AAED,QAAI,KAAK;AACR,kBAAY,MAAM;AAEb,YAAA,MAAM,cAAc,MAAM,YAAY;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"PrismicRichText.vue.js","sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n\ttype HTMLRichTextFunctionSerializer,\n\ttype HTMLRichTextMapSerializer,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport { DEV } from \"esm-env\"\nimport type { PropType } from \"vue\"\nimport { computed, watchEffect } from \"vue\"\n\nimport Wrapper from \"../lib/Wrapper.vue\"\n\nimport type { ComponentOrTagName } from \"../types\"\nimport type { VueRichTextSerializer } from \"./types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport DeprecatedPrismicRichText from \"./DeprecatedPrismicRichText.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `components` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\t// TODO: Remove in v6\n\tserializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer\n\n\t/**\n\t * An HTML tag name or a component used to wrap the output. `<PrismicText />`\n\t * is not wrapped by default.\n\t *\n\t * @defaultValue `\"template\"` (no wrapper)\n\t */\n\twrapper?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tserializer: {\n\t\ttype: [Object, Function] as PropType<PrismicRichTextProps[\"serializer\"]>,\n\t},\n\twrapper: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"wrapper\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { options } = usePrismic()\n\nconst resolvedComponents = computed(() => {\n\treturn props.components || options.components?.richTextComponents\n})\n\nconst resolvedLinkResolver = computed(() => {\n\treturn props.linkResolver || options.linkResolver\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nconst isModern = computed(() => {\n\t// Explicit components prop\n\tif (props.components) {\n\t\treturn true\n\t}\n\n\t// Explicit serializer prop\n\tif (props.serializer) {\n\t\treturn false\n\t}\n\n\t// Global components option\n\tif (options.components?.richTextComponents) {\n\t\treturn true\n\t}\n\n\t// Global serializer option\n\tif (options.richTextSerializer) {\n\t\treturn false\n\t}\n\n\t// Default to modern\n\treturn true\n})\n\nif (DEV) {\n\twatchEffect(() => {\n\t\t// TODO: Remove in v6\n\t\tif (props.components && props.serializer) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] Only one of \"components\" or \"serializer\" (deprecated) props can be provided. You can resolve this warning by removing either the \"components\" or \"serializer\" prop. \"components\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n</script>\n\n<template>\n\t<Wrapper\n\t\tv-if=\"isModern && (isFilled.richText(field) || fallback)\"\n\t\t:wrapper=\"wrapper\"\n\t>\n\t\t<PrismicRichTextSerialize\n\t\t\tv-if=\"children.length\"\n\t\t\t:children=\"children\"\n\t\t\t:components=\"resolvedComponents\"\n\t\t\t:link-resolver=\"resolvedLinkResolver\"\n\t\t/>\n\t\t<component v-else :is=\"fallback\" />\n\t</Wrapper>\n\t<DeprecatedPrismicRichText\n\t\tv-else-if=\"!isModern\"\n\t\t:field=\"field\"\n\t\t:fallback=\"typeof fallback === 'string' ? fallback : undefined\"\n\t\t:link-resolver=\"linkResolver\"\n\t\t:serializer=\"serializer\"\n\t\t:wrapper=\"wrapper\"\n\t/>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,UAAM,QAAQ;AA0BR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAEzB,UAAA,qBAAqB,SAAS,MAAM;;AAClC,aAAA,MAAM,gBAAc,aAAQ,eAAR,mBAAoB;AAAA,IAAA,CAC/C;AAEK,UAAA,uBAAuB,SAAS,MAAM;AACpC,aAAA,MAAM,gBAAgB,QAAQ;AAAA,IAAA,CACrC;AAEK,UAAA,WAAW,SAAS,MAAM;AAC/B,aAAO,OAAO,MAAM,SAAS,CAAA,CAAE,EAAE;AAAA,IAAA,CACjC;AAEK,UAAA,WAAW,SAAS,MAAM;;AAE/B,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIR,UAAI,MAAM,YAAY;AACd,eAAA;AAAA,MAAA;AAIJ,WAAA,aAAQ,eAAR,mBAAoB,oBAAoB;AACpC,eAAA;AAAA,MAAA;AAIR,UAAI,QAAQ,oBAAoB;AACxB,eAAA;AAAA,MAAA;AAID,aAAA;AAAA,IAAA,CACP;AAED,QAAI,KAAK;AACR,kBAAY,MAAM;AAEb,YAAA,MAAM,cAAc,MAAM,YAAY;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, renderSlot, createBlock, withCtx, createVNode, normalizeClass, Fragment, renderList, createCommentVNode, createTextVNode, toDisplayString } from "vue";
1
+ import { defineComponent, computed, createElementBlock, createBlock, openBlock, renderSlot, withCtx, createVNode, normalizeClass, Fragment, renderList, createCommentVNode, createTextVNode, toDisplayString } from "vue";
2
2
  import _sfc_main$3 from "../PrismicEmbed.vue.js";
3
3
  import _sfc_main$2 from "../PrismicImage.vue.js";
4
4
  import _sfc_main$1 from "../PrismicLink.vue.js";
@@ -1,4 +1,4 @@
1
- import { defineComponent, resolveComponent, openBlock, createElementBlock, Fragment, renderList, createBlock, resolveDynamicComponent, withCtx, createCommentVNode } from "vue";
1
+ import { defineComponent, resolveComponent, createElementBlock, openBlock, Fragment, renderList, createBlock, resolveDynamicComponent, withCtx, createCommentVNode } from "vue";
2
2
  import _sfc_main$1 from "./PrismicRichTextDefaultComponent.vue.js";
3
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  ...{ name: "PrismicRichTextSerialize" },
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, unref, openBlock, createBlock, resolveDynamicComponent, mergeProps, withCtx, createElementBlock, Fragment, renderList, createCommentVNode } from "vue";
1
+ import { defineComponent, computed, createBlock, unref, openBlock, resolveDynamicComponent, mergeProps, withCtx, createCommentVNode, createElementBlock, Fragment, renderList } from "vue";
2
2
  import { isFilled } from "@prismicio/client";
3
3
  import { defaultTableComponents } from "./PrismicTableDefaultComponents.js";
4
4
  import _sfc_main$1 from "./PrismicTableRow.vue.js";
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, h } from "vue";
2
- import { table, thead, tbody, tr, th, td } from "./getTableComponentProps.js";
2
+ import { td, th, tr, tbody, thead, table } from "./getTableComponentProps.js";
3
3
  const defaultTableComponents = {
4
4
  table: defineComponent({
5
5
  props: table(),
@@ -1,4 +1,4 @@
1
- import { defineComponent, openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock, Fragment, renderList, createVNode } from "vue";
1
+ import { defineComponent, createBlock, openBlock, resolveDynamicComponent, withCtx, createElementBlock, Fragment, renderList, createVNode } from "vue";
2
2
  import _sfc_main$1 from "../PrismicRichText/PrismicRichText.vue.js";
3
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  ...{ name: "PrismicTableRow" },
@@ -1,4 +1,4 @@
1
- import { defineComponent, watchEffect, unref, openBlock, createBlock, withCtx, createTextVNode, toDisplayString, createCommentVNode } from "vue";
1
+ import { defineComponent, watchEffect, createBlock, createCommentVNode, unref, openBlock, withCtx, createTextVNode, toDisplayString } from "vue";
2
2
  import { isFilled, asText } from "@prismicio/client";
3
3
  import { DEV } from "esm-env";
4
4
  import _sfc_main$1 from "./lib/Wrapper.vue.js";
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, resolveDynamicComponent, mergeProps, createCommentVNode } from "vue";
1
+ import { defineComponent, computed, createBlock, createCommentVNode, openBlock, withCtx, createElementBlock, Fragment, renderList, resolveDynamicComponent, mergeProps } from "vue";
2
2
  import _sfc_main$1 from "../lib/Wrapper.vue.js";
3
3
  import { usePrismic } from "../usePrismic.js";
4
4
  import { TODOSliceComponent } from "./TODOSliceComponent.js";
@@ -1,4 +1,4 @@
1
- import { createClient, filter, cookie, asText, asHTML, asLink, asLinkAttrs, asDate, asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet, isFilled, documentToLinkField } from "@prismicio/client";
1
+ import { createClient, documentToLinkField, isFilled, asImagePixelDensitySrcSet, asImageWidthSrcSet, asImageSrc, asDate, asText, cookie, filter, asLinkAttrs, asLink, asHTML } from "@prismicio/client";
2
2
  import _sfc_main$5 from "./PrismicRichText/PrismicRichText.vue.js";
3
3
  import _sfc_main$3 from "./PrismicTable/PrismicTable.vue.js";
4
4
  import _sfc_main$6 from "./SliceZone/SliceZone.vue.js";
@@ -1,4 +1,4 @@
1
- import { defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, renderSlot } from "vue";
1
+ import { defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx } from "vue";
2
2
  const _sfc_main = /* @__PURE__ */ defineComponent({
3
3
  __name: "Wrapper",
4
4
  props: {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "5.2.0";
3
+ const version = "5.3.0";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- const version = "5.2.0";
1
+ const version = "5.3.0";
2
2
  export {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/vue",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "Vue plugin, components, and composables to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -57,39 +57,39 @@
57
57
  "test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
58
58
  },
59
59
  "dependencies": {
60
- "@prismicio/client": "^7.17.0",
60
+ "@prismicio/client": "^7.17.1",
61
61
  "esm-env": "^1.2.2",
62
62
  "vue-router": "^4.5.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@eslint/js": "^9.18.0",
65
+ "@eslint/js": "^9.23.0",
66
66
  "@prismicio/mock": "^0.7.1",
67
- "@size-limit/preset-small-lib": "^11.1.6",
68
- "@trivago/prettier-plugin-sort-imports": "^5.2.1",
67
+ "@size-limit/preset-small-lib": "^11.2.0",
68
+ "@trivago/prettier-plugin-sort-imports": "^5.2.2",
69
69
  "@types/jsdom-global": "^3.0.7",
70
- "@vitejs/plugin-vue": "^5.2.1",
71
- "@vitest/coverage-v8": "^3.0.2",
72
- "@vue/eslint-config-typescript": "^14.2.0",
70
+ "@vitejs/plugin-vue": "^5.2.3",
71
+ "@vitest/coverage-v8": "^3.0.9",
72
+ "@vue/eslint-config-typescript": "^14.5.0",
73
73
  "@vue/test-utils": "^2.4.6",
74
- "eslint": "^9.18.0",
75
- "eslint-config-prettier": "^10.0.1",
76
- "eslint-plugin-prettier": "^5.2.3",
74
+ "eslint": "^9.23.0",
75
+ "eslint-config-prettier": "^10.1.1",
76
+ "eslint-plugin-prettier": "^5.2.5",
77
77
  "eslint-plugin-tsdoc": "^0.4.0",
78
- "eslint-plugin-vue": "^9.32.0",
78
+ "eslint-plugin-vue": "^10.0.0",
79
79
  "jsdom": "^26.0.0",
80
80
  "jsdom-global": "^3.0.2",
81
- "prettier": "^3.4.2",
81
+ "prettier": "^3.5.3",
82
82
  "prettier-plugin-jsdoc": "^1.3.2",
83
- "size-limit": "^11.1.6",
83
+ "size-limit": "^11.2.0",
84
84
  "standard-version": "^9.5.0",
85
- "typescript": "~5.7.3",
86
- "typescript-eslint": "^8.21.0",
87
- "vite": "^6.0.9",
88
- "vite-plugin-dts": "^4.5.0",
85
+ "typescript": "^5.8.2",
86
+ "typescript-eslint": "^8.28.0",
87
+ "vite": "^6.2.3",
88
+ "vite-plugin-dts": "^4.5.3",
89
89
  "vite-plugin-sdk": "^0.1.3",
90
- "vitest": "^3.0.2",
90
+ "vitest": "^3.0.9",
91
91
  "vue": "^3.5.13",
92
- "vue-tsc": "^2.2.0"
92
+ "vue-tsc": "^2.2.8"
93
93
  },
94
94
  "peerDependencies": {
95
95
  "vue": "^3.0.0"
@@ -44,6 +44,22 @@ export type PrismicImageProps = {
44
44
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
45
45
  */
46
46
  fallbackAlt?: ""
47
+
48
+ /**
49
+ * The width attribute of the image element.
50
+ *
51
+ * See:
52
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
53
+ */
54
+ width?: number | string
55
+
56
+ /**
57
+ * The height attribute of the image element.
58
+ *
59
+ * See:
60
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
61
+ */
62
+ height?: number | string
47
63
  } & (
48
64
  | {
49
65
  /**
@@ -116,6 +132,20 @@ if (DEV) {
116
132
  })
117
133
  }
118
134
 
135
+ const castInt = (input: string | number | undefined): number | undefined => {
136
+ if (typeof input === "number" || typeof input === "undefined") {
137
+ return input
138
+ } else {
139
+ const parsed = Number.parseInt(input)
140
+
141
+ if (Number.isNaN(parsed)) {
142
+ return undefined
143
+ } else {
144
+ return parsed
145
+ }
146
+ }
147
+ }
148
+
119
149
  const image = computed(() => {
120
150
  if (!isFilled.imageThumbnail(props.field)) {
121
151
  return
@@ -147,14 +177,37 @@ const image = computed(() => {
147
177
  srcSet = res.srcset
148
178
  }
149
179
 
180
+ const ar = props.field.dimensions.width / props.field.dimensions.height
181
+
182
+ const castedWidth = castInt(props.width)
183
+ const castedHeight = castInt(props.height)
184
+
185
+ let resolvedWidth = castedWidth ?? props.field.dimensions.width
186
+ let resolvedHeight = castedHeight ?? props.field.dimensions.height
187
+
188
+ if (castedWidth != null && castedHeight == null) {
189
+ resolvedHeight = castedWidth / ar
190
+ } else if (castedWidth == null && castedHeight != null) {
191
+ resolvedWidth = castedHeight * ar
192
+ }
193
+
150
194
  return {
151
195
  src,
152
196
  srcSet,
153
197
  alt: props.alt ?? (props.field.alt || props.fallbackAlt),
198
+ width: Math.round(resolvedWidth),
199
+ height: Math.round(resolvedHeight),
154
200
  }
155
201
  })
156
202
  </script>
157
203
 
158
204
  <template>
159
- <img v-if="image" :src="image.src" :srcset="image.srcSet" :alt="image.alt" />
205
+ <img
206
+ v-if="image"
207
+ :src="image.src"
208
+ :srcset="image.srcSet"
209
+ :alt="image.alt"
210
+ :width="image.width"
211
+ :height="image.height"
212
+ />
160
213
  </template>
@@ -2,7 +2,7 @@
2
2
  // TODO: Remove in v6
3
3
  import { asHTML, isFilled } from "@prismicio/client"
4
4
  import { DEV } from "esm-env"
5
- import type { Component } from "vue"
5
+ import type { Component, PropType } from "vue"
6
6
  import {
7
7
  computed,
8
8
  inject,
@@ -26,12 +26,27 @@ import type { PrismicRichTextProps } from "./PrismicRichText.vue"
26
26
  */
27
27
  const defaultWrapper = "div"
28
28
 
29
- const props = defineProps<
30
- Pick<
31
- PrismicRichTextProps,
32
- "field" | "linkResolver" | "serializer" | "wrapper"
33
- > & { fallback?: string }
34
- >()
29
+ // We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`
30
+ // has limitations for inferring types from complex objects.
31
+ const props = defineProps({
32
+ field: {
33
+ type: Array as unknown as PropType<PrismicRichTextProps["field"]>,
34
+ },
35
+ fallback: {
36
+ type: String as PropType<string>,
37
+ },
38
+ linkResolver: {
39
+ type: Function as PropType<PrismicRichTextProps["linkResolver"]>,
40
+ },
41
+ serializer: {
42
+ type: [Object, Function] as PropType<PrismicRichTextProps["serializer"]>,
43
+ },
44
+ wrapper: {
45
+ type: [String, Object, Function] as PropType<
46
+ PrismicRichTextProps["wrapper"]
47
+ >,
48
+ },
49
+ })
35
50
  defineOptions({ name: "DeprecatedPrismicRichText" })
36
51
 
37
52
  const { options } = usePrismic()
@@ -8,6 +8,7 @@ import {
8
8
  } from "@prismicio/client"
9
9
  import { asTree } from "@prismicio/client/richtext"
10
10
  import { DEV } from "esm-env"
11
+ import type { PropType } from "vue"
11
12
  import { computed, watchEffect } from "vue"
12
13
 
13
14
  import Wrapper from "../lib/Wrapper.vue"
@@ -79,7 +80,32 @@ export type PrismicRichTextProps = {
79
80
  wrapper?: ComponentOrTagName
80
81
  }
81
82
 
82
- const props = defineProps<PrismicRichTextProps>()
83
+ // We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`
84
+ // has limitations for inferring types from complex objects.
85
+ const props = defineProps({
86
+ field: {
87
+ type: Array as unknown as PropType<PrismicRichTextProps["field"]>,
88
+ },
89
+ fallback: {
90
+ type: [String, Object, Function] as PropType<
91
+ PrismicRichTextProps["fallback"]
92
+ >,
93
+ },
94
+ components: {
95
+ type: Object as PropType<PrismicRichTextProps["components"]>,
96
+ },
97
+ linkResolver: {
98
+ type: Function as PropType<PrismicRichTextProps["linkResolver"]>,
99
+ },
100
+ serializer: {
101
+ type: [Object, Function] as PropType<PrismicRichTextProps["serializer"]>,
102
+ },
103
+ wrapper: {
104
+ type: [String, Object, Function] as PropType<
105
+ PrismicRichTextProps["wrapper"]
106
+ >,
107
+ },
108
+ })
83
109
  defineOptions({ name: "PrismicRichText" })
84
110
 
85
111
  const { options } = usePrismic()