@prismicio/vue 5.2.0 → 5.2.1

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.
@@ -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({
@@ -1,4 +1,4 @@
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";
@@ -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.2.1";
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.2.1";
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.2.1",
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"
@@ -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()