@prismicio/react 2.9.1 → 3.0.0-alpha.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.
- package/README.md +10 -11
- package/dist/PrismicImage.d.ts +18 -633
- package/dist/PrismicImage.js +32 -33
- package/dist/PrismicImage.js.map +1 -1
- package/dist/PrismicLink.d.ts +77 -6
- package/dist/PrismicLink.js +42 -7
- package/dist/PrismicLink.js.map +1 -1
- package/dist/PrismicRichText.d.ts +117 -4
- package/dist/PrismicRichText.js +74 -8
- package/dist/PrismicRichText.js.map +1 -1
- package/dist/PrismicText.d.ts +8 -13
- package/dist/PrismicText.js +15 -16
- package/dist/PrismicText.js.map +1 -1
- package/dist/PrismicToolbar.d.ts +2 -12
- package/dist/PrismicToolbar.js +8 -10
- package/dist/PrismicToolbar.js.map +1 -1
- package/dist/SliceZone.d.ts +16 -70
- package/dist/SliceZone.js +16 -37
- package/dist/SliceZone.js.map +1 -1
- package/dist/index.d.ts +13 -21
- package/dist/index.js +2 -29
- package/dist/index.js.map +1 -1
- package/dist/lib/devMsg.d.ts +2 -2
- package/dist/lib/devMsg.js +2 -2
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +53 -70
- package/src/PrismicImage.tsx +80 -65
- package/src/PrismicLink.tsx +196 -26
- package/src/PrismicRichText.tsx +333 -33
- package/src/PrismicText.tsx +25 -30
- package/src/PrismicToolbar.tsx +10 -30
- package/src/SliceZone.tsx +58 -150
- package/src/index.ts +17 -53
- package/src/lib/devMsg.ts +3 -3
- package/dist/PrismicImage.cjs +0 -68
- package/dist/PrismicImage.cjs.map +0 -1
- package/dist/PrismicLink.cjs +0 -29
- package/dist/PrismicLink.cjs.map +0 -1
- package/dist/PrismicProvider.cjs +0 -41
- package/dist/PrismicProvider.cjs.map +0 -1
- package/dist/PrismicProvider.d.ts +0 -83
- package/dist/PrismicProvider.js +0 -24
- package/dist/PrismicProvider.js.map +0 -1
- package/dist/PrismicRichText.cjs +0 -30
- package/dist/PrismicRichText.cjs.map +0 -1
- package/dist/PrismicText.cjs +0 -44
- package/dist/PrismicText.cjs.map +0 -1
- package/dist/PrismicToolbar.cjs +0 -43
- package/dist/PrismicToolbar.cjs.map +0 -1
- package/dist/SliceZone.cjs +0 -53
- package/dist/SliceZone.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs +0 -16
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js +0 -16
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs +0 -13
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js +0 -13
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs +0 -22
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js +0 -22
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs +0 -46
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js +0 -46
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +0 -47
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +0 -47
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs +0 -28
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js +0 -28
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs +0 -21
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js +0 -21
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +0 -27
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +0 -27
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs +0 -24
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js +0 -24
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs +0 -7
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js +0 -7
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs +0 -9
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js +0 -9
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.cjs +0 -13
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.js +0 -13
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs +0 -10
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js +0 -10
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.cjs +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.js +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.js.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.cjs +0 -29
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.js +0 -29
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.js.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.cjs +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.js +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.js.map +0 -1
- package/dist/clientHooks.cjs +0 -40
- package/dist/clientHooks.cjs.map +0 -1
- package/dist/clientHooks.d.ts +0 -321
- package/dist/clientHooks.js +0 -40
- package/dist/clientHooks.js.map +0 -1
- package/dist/index.cjs +0 -48
- package/dist/index.cjs.map +0 -1
- package/dist/lib/devMsg.cjs +0 -8
- package/dist/lib/devMsg.cjs.map +0 -1
- package/dist/lib/isInternalURL.cjs +0 -9
- package/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/lib/isInternalURL.d.ts +0 -8
- package/dist/lib/isInternalURL.js +0 -9
- package/dist/lib/isInternalURL.js.map +0 -1
- package/dist/lib/pascalCase.cjs +0 -10
- package/dist/lib/pascalCase.cjs.map +0 -1
- package/dist/lib/pascalCase.d.ts +0 -26
- package/dist/lib/pascalCase.js +0 -10
- package/dist/lib/pascalCase.js.map +0 -1
- package/dist/package.json.cjs +0 -5
- package/dist/package.json.cjs.map +0 -1
- package/dist/react-server/PrismicLink.cjs +0 -59
- package/dist/react-server/PrismicLink.cjs.map +0 -1
- package/dist/react-server/PrismicLink.d.ts +0 -77
- package/dist/react-server/PrismicLink.js +0 -42
- package/dist/react-server/PrismicLink.js.map +0 -1
- package/dist/react-server/PrismicRichText.cjs +0 -102
- package/dist/react-server/PrismicRichText.cjs.map +0 -1
- package/dist/react-server/PrismicRichText.d.ts +0 -104
- package/dist/react-server/PrismicRichText.js +0 -84
- package/dist/react-server/PrismicRichText.js.map +0 -1
- package/dist/react-server/index.d.ts +0 -4
- package/dist/react-server/unsupported.cjs +0 -97
- package/dist/react-server/unsupported.cjs.map +0 -1
- package/dist/react-server/unsupported.d.ts +0 -22
- package/dist/react-server/unsupported.js +0 -97
- package/dist/react-server/unsupported.js.map +0 -1
- package/dist/react-server.cjs +0 -44
- package/dist/react-server.cjs.map +0 -1
- package/dist/react-server.js +0 -41
- package/dist/react-server.js.map +0 -1
- package/dist/types.d.ts +0 -19
- package/dist/usePrismicClient.cjs +0 -13
- package/dist/usePrismicClient.cjs.map +0 -1
- package/dist/usePrismicClient.d.ts +0 -11
- package/dist/usePrismicClient.js +0 -13
- package/dist/usePrismicClient.js.map +0 -1
- package/dist/usePrismicContext.cjs +0 -26
- package/dist/usePrismicContext.cjs.map +0 -1
- package/dist/usePrismicContext.d.ts +0 -8
- package/dist/usePrismicContext.js +0 -9
- package/dist/usePrismicContext.js.map +0 -1
- package/dist/usePrismicPreviewResolver.cjs +0 -44
- package/dist/usePrismicPreviewResolver.cjs.map +0 -1
- package/dist/usePrismicPreviewResolver.d.ts +0 -45
- package/dist/usePrismicPreviewResolver.js +0 -27
- package/dist/usePrismicPreviewResolver.js.map +0 -1
- package/dist/useStatefulPrismicClientMethod.cjs +0 -91
- package/dist/useStatefulPrismicClientMethod.cjs.map +0 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +0 -44
- package/dist/useStatefulPrismicClientMethod.js +0 -74
- package/dist/useStatefulPrismicClientMethod.js.map +0 -1
- package/src/PrismicProvider.tsx +0 -132
- package/src/clientHooks.ts +0 -472
- package/src/lib/isInternalURL.ts +0 -14
- package/src/lib/pascalCase.ts +0 -79
- package/src/react-server/PrismicLink.tsx +0 -197
- package/src/react-server/PrismicRichText.tsx +0 -326
- package/src/react-server/index.ts +0 -38
- package/src/react-server/unsupported.ts +0 -184
- package/src/types.ts +0 -23
- package/src/usePrismicClient.ts +0 -30
- package/src/usePrismicContext.ts +0 -13
- package/src/usePrismicPreviewResolver.ts +0 -93
- package/src/useStatefulPrismicClientMethod.ts +0 -196
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const asLinkAttrs = require('./../_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs');
|
|
6
|
-
const devMsg = require("../lib/devMsg.cjs");
|
|
7
|
-
const isInternalURL = require("../lib/isInternalURL.cjs");
|
|
8
|
-
function _interopNamespaceDefault(e) {
|
|
9
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
-
if (e) {
|
|
11
|
-
for (const k in e) {
|
|
12
|
-
if (k !== "default") {
|
|
13
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: () => e[k]
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
25
|
-
const defaultComponent = "a";
|
|
26
|
-
const PrismicLink = React__namespace.forwardRef(function PrismicLink2(props, ref) {
|
|
27
|
-
const { field, document: doc, linkResolver, internalComponent, externalComponent, children, ...restProps } = props;
|
|
28
|
-
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
29
|
-
if (field) {
|
|
30
|
-
if (!field.link_type) {
|
|
31
|
-
console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
|
|
32
|
-
`, field);
|
|
33
|
-
throw new Error(`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg.devMsg("missing-link-properties")}`);
|
|
34
|
-
} else if (("text" in field ? Object.keys(field).length > 2 : Object.keys(field).length > 1) && !("url" in field || "uid" in field || "id" in field)) {
|
|
35
|
-
console.warn(`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg.devMsg("missing-link-properties")}`, field);
|
|
36
|
-
}
|
|
37
|
-
} else if (doc) {
|
|
38
|
-
if (!("url" in doc || "id" in doc)) {
|
|
39
|
-
console.warn(`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg.devMsg("missing-link-properties")}`, doc);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs.asLinkAttrs(field ?? doc, {
|
|
44
|
-
linkResolver,
|
|
45
|
-
rel: typeof restProps.rel === "function" ? restProps.rel : void 0
|
|
46
|
-
});
|
|
47
|
-
let rel = computedRel;
|
|
48
|
-
if ("rel" in restProps && typeof restProps.rel !== "function") {
|
|
49
|
-
rel = restProps.rel;
|
|
50
|
-
}
|
|
51
|
-
const href = ("href" in restProps ? restProps.href : computedHref) || "";
|
|
52
|
-
const InternalComponent = internalComponent || defaultComponent;
|
|
53
|
-
const ExternalComponent = externalComponent || defaultComponent;
|
|
54
|
-
const Component = href && isInternalURL.isInternalURL(href) ? InternalComponent : ExternalComponent;
|
|
55
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, ...attrs, ...restProps, href, rel, children: "children" in props ? children : field == null ? void 0 : field.text });
|
|
56
|
-
});
|
|
57
|
-
exports.PrismicLink = PrismicLink;
|
|
58
|
-
exports.defaultComponent = defaultComponent;
|
|
59
|
-
//# sourceMappingURL=PrismicLink.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.cjs","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: React.HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<\n\tInternalComponentProps & ExternalComponentProps,\n\t\"rel\" | \"href\" | \"children\"\n> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\n\n\t/**\n\t * The children to render for the link. If no children are provided, the\n\t * link's `text` property will be used.\n\t */\n\tchildren?: React.ReactNode;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tconst {\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\tif (\n\t\ttypeof process !== \"undefined\" &&\n\t\tprocess.env.NODE_ENV === \"development\"\n\t) {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\t(\"text\" in field\n\t\t\t\t\t? Object.keys(field).length > 2\n\t\t\t\t\t: Object.keys(field).length > 1) &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</Component>\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["React","PrismicLink","devMsg","asLinkAttrs","isInternalURL","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAM,mBAAmB;AAyFzB,MAAM,cAAcA,iBAAM,WAAW,SAASC,aAIpD,OACA,KAAgC;AAE1B,QAAA,EACL,OACA,UAAU,KACV,cACA,mBACA,mBACA,UACA,GAAG,UAAA,IACA;AAEJ,MACC,OAAO,YAAY,eACnB,QAAQ,IAAI,aAAa,eACxB;AACD,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8IC,OAAA,OAC7I,yBAAyB,GACvB;AAAA,MAAA,YAGH,UAAU,QACR,OAAO,KAAK,KAAK,EAAE,SAAS,IAC5B,OAAO,KAAK,KAAK,EAAE,SAAS,MAC/B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJA,OAAAA,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0JA,OAAAA,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACAC,YAAAA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQC,cAAAA,cAAc,IAAI,IAAI,oBAAoB;AAEnD,SACEC,2BAAAA,IAAA,WAAA,EAAU,KAAc,GAAA,OAAW,GAAA,WAAW,MAAY,KACzD,UAAA,cAAc,QAAQ,WAAW,+BAAO,KAC1C,CAAA;AAEF,CAAC;;;"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { LinkField, LinkResolverFunction, PrismicDocument, AsLinkAttrsConfig } from "@prismicio/client";
|
|
3
|
-
/**
|
|
4
|
-
* The default component rendered for internal and external links.
|
|
5
|
-
*/
|
|
6
|
-
export declare const defaultComponent = "a";
|
|
7
|
-
/**
|
|
8
|
-
* Props provided to a component when rendered with `<PrismicLink>`.
|
|
9
|
-
*/
|
|
10
|
-
export interface LinkProps {
|
|
11
|
-
/**
|
|
12
|
-
* The URL to link.
|
|
13
|
-
*/
|
|
14
|
-
href: string;
|
|
15
|
-
/**
|
|
16
|
-
* The `target` attribute for anchor elements. If the Prismic field is
|
|
17
|
-
* configured to open in a new window, this prop defaults to `_blank`.
|
|
18
|
-
*/
|
|
19
|
-
target?: React.HTMLAttributeAnchorTarget;
|
|
20
|
-
/**
|
|
21
|
-
* The `rel` attribute for anchor elements. If the `target` prop is set to
|
|
22
|
-
* `"_blank"`, this prop defaults to `"noopener noreferrer"`.
|
|
23
|
-
*/
|
|
24
|
-
rel?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Children for the component. *
|
|
27
|
-
*/
|
|
28
|
-
children?: React.ReactNode;
|
|
29
|
-
}
|
|
30
|
-
export type PrismicLinkProps<InternalComponentProps = React.ComponentProps<typeof defaultComponent>, ExternalComponentProps = React.ComponentProps<typeof defaultComponent>> = Omit<InternalComponentProps & ExternalComponentProps, "rel" | "href" | "children"> & {
|
|
31
|
-
/**
|
|
32
|
-
* The `rel` attribute for the link. By default, `"noreferrer"` is provided if
|
|
33
|
-
* the link's URL is external. This prop can be provided a function to use the
|
|
34
|
-
* link's metadata to determine the `rel` value.
|
|
35
|
-
*/
|
|
36
|
-
rel?: string | AsLinkAttrsConfig["rel"];
|
|
37
|
-
/**
|
|
38
|
-
* The Link Resolver used to resolve links.
|
|
39
|
-
*
|
|
40
|
-
* @remarks
|
|
41
|
-
* If your app uses Route Resolvers when querying for your Prismic
|
|
42
|
-
* repository's content, a Link Resolver does not need to be provided.
|
|
43
|
-
* @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
44
|
-
*/
|
|
45
|
-
linkResolver?: LinkResolverFunction;
|
|
46
|
-
/**
|
|
47
|
-
* The component rendered for internal URLs. Defaults to `<a>`.
|
|
48
|
-
*
|
|
49
|
-
* If your app uses a client-side router that requires a special Link
|
|
50
|
-
* component, provide the Link component to this prop.
|
|
51
|
-
*/
|
|
52
|
-
internalComponent?: React.ElementType<InternalComponentProps>;
|
|
53
|
-
/**
|
|
54
|
-
* The component rendered for external URLs. Defaults to `<a>`.
|
|
55
|
-
*/
|
|
56
|
-
externalComponent?: React.ComponentType<ExternalComponentProps>;
|
|
57
|
-
/**
|
|
58
|
-
* The children to render for the link. If no children are provided, the
|
|
59
|
-
* link's `text` property will be used.
|
|
60
|
-
*/
|
|
61
|
-
children?: React.ReactNode;
|
|
62
|
-
} & ({
|
|
63
|
-
document: PrismicDocument | null | undefined;
|
|
64
|
-
href?: never;
|
|
65
|
-
field?: never;
|
|
66
|
-
} | {
|
|
67
|
-
field: LinkField | null | undefined;
|
|
68
|
-
href?: never;
|
|
69
|
-
document?: never;
|
|
70
|
-
} | {
|
|
71
|
-
href: LinkProps["href"];
|
|
72
|
-
field?: LinkField | null | undefined;
|
|
73
|
-
document?: never;
|
|
74
|
-
});
|
|
75
|
-
export declare const PrismicLink: <InternalComponentProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, ExternalComponentProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>>(props: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {
|
|
76
|
-
ref?: React.ForwardedRef<Element> | undefined;
|
|
77
|
-
}) => JSX.Element;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { asLinkAttrs } from './../_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js';
|
|
4
|
-
import { devMsg } from "../lib/devMsg.js";
|
|
5
|
-
import { isInternalURL } from "../lib/isInternalURL.js";
|
|
6
|
-
const defaultComponent = "a";
|
|
7
|
-
const PrismicLink = React.forwardRef(function PrismicLink2(props, ref) {
|
|
8
|
-
const { field, document: doc, linkResolver, internalComponent, externalComponent, children, ...restProps } = props;
|
|
9
|
-
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
10
|
-
if (field) {
|
|
11
|
-
if (!field.link_type) {
|
|
12
|
-
console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
|
|
13
|
-
`, field);
|
|
14
|
-
throw new Error(`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg("missing-link-properties")}`);
|
|
15
|
-
} else if (("text" in field ? Object.keys(field).length > 2 : Object.keys(field).length > 1) && !("url" in field || "uid" in field || "id" in field)) {
|
|
16
|
-
console.warn(`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, field);
|
|
17
|
-
}
|
|
18
|
-
} else if (doc) {
|
|
19
|
-
if (!("url" in doc || "id" in doc)) {
|
|
20
|
-
console.warn(`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, doc);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? doc, {
|
|
25
|
-
linkResolver,
|
|
26
|
-
rel: typeof restProps.rel === "function" ? restProps.rel : void 0
|
|
27
|
-
});
|
|
28
|
-
let rel = computedRel;
|
|
29
|
-
if ("rel" in restProps && typeof restProps.rel !== "function") {
|
|
30
|
-
rel = restProps.rel;
|
|
31
|
-
}
|
|
32
|
-
const href = ("href" in restProps ? restProps.href : computedHref) || "";
|
|
33
|
-
const InternalComponent = internalComponent || defaultComponent;
|
|
34
|
-
const ExternalComponent = externalComponent || defaultComponent;
|
|
35
|
-
const Component = href && isInternalURL(href) ? InternalComponent : ExternalComponent;
|
|
36
|
-
return /* @__PURE__ */ jsx(Component, { ref, ...attrs, ...restProps, href, rel, children: "children" in props ? children : field == null ? void 0 : field.text });
|
|
37
|
-
});
|
|
38
|
-
export {
|
|
39
|
-
PrismicLink,
|
|
40
|
-
defaultComponent
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=PrismicLink.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.js","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: React.HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<\n\tInternalComponentProps & ExternalComponentProps,\n\t\"rel\" | \"href\" | \"children\"\n> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\n\n\t/**\n\t * The children to render for the link. If no children are provided, the\n\t * link's `text` property will be used.\n\t */\n\tchildren?: React.ReactNode;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tconst {\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\tif (\n\t\ttypeof process !== \"undefined\" &&\n\t\tprocess.env.NODE_ENV === \"development\"\n\t) {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\t(\"text\" in field\n\t\t\t\t\t? Object.keys(field).length > 2\n\t\t\t\t\t: Object.keys(field).length > 1) &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</Component>\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["PrismicLink"],"mappings":";;;;;AAeO,MAAM,mBAAmB;AAyFzB,MAAM,cAAc,MAAM,WAAW,SAASA,aAIpD,OACA,KAAgC;AAE1B,QAAA,EACL,OACA,UAAU,KACV,cACA,mBACA,mBACA,UACA,GAAG,UAAA,IACA;AAEJ,MACC,OAAO,YAAY,eACnB,QAAQ,IAAI,aAAa,eACxB;AACD,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8I,OAC7I,yBAAyB,GACvB;AAAA,MAAA,YAGH,UAAU,QACR,OAAO,KAAK,KAAK,EAAE,SAAS,IAC5B,OAAO,KAAK,KAAK,EAAE,SAAS,MAC/B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJ,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0J,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQ,cAAc,IAAI,IAAI,oBAAoB;AAEnD,SACE,oBAAA,WAAA,EAAU,KAAc,GAAA,OAAW,GAAA,WAAW,MAAY,KACzD,UAAA,cAAc,QAAQ,WAAW,+BAAO,KAC1C,CAAA;AAEF,CAAC;"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const prismicR = require("@prismicio/richtext");
|
|
6
|
-
const PrismicLink = require("./PrismicLink.cjs");
|
|
7
|
-
const devMsg = require("../lib/devMsg.cjs");
|
|
8
|
-
const isFilled = require('./../_node_modules/@prismicio/client/dist/helpers/isFilled.cjs');
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
|
-
if (e) {
|
|
12
|
-
for (const k in e) {
|
|
13
|
-
if (k !== "default") {
|
|
14
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: () => e[k]
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
-
const prismicR__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismicR);
|
|
27
|
-
const getDir = (node) => {
|
|
28
|
-
if ("direction" in node && node.direction === "rtl") {
|
|
29
|
-
return "rtl";
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const createDefaultSerializer = (args) => prismicR__namespace.wrapMapSerializer({
|
|
33
|
-
heading1: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { dir: getDir(node), children }, key),
|
|
34
|
-
heading2: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { dir: getDir(node), children }, key),
|
|
35
|
-
heading3: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { dir: getDir(node), children }, key),
|
|
36
|
-
heading4: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { dir: getDir(node), children }, key),
|
|
37
|
-
heading5: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { dir: getDir(node), children }, key),
|
|
38
|
-
heading6: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h6", { dir: getDir(node), children }, key),
|
|
39
|
-
paragraph: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("p", { dir: getDir(node), children }, key),
|
|
40
|
-
preformatted: ({ node, key }) => /* @__PURE__ */ jsxRuntime.jsx("pre", { children: node.text }, key),
|
|
41
|
-
strong: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { children }, key),
|
|
42
|
-
em: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("em", { children }, key),
|
|
43
|
-
listItem: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("li", { dir: getDir(node), children }, key),
|
|
44
|
-
oListItem: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("li", { dir: getDir(node), children }, key),
|
|
45
|
-
list: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { children }, key),
|
|
46
|
-
oList: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { children }, key),
|
|
47
|
-
image: ({ node, key }) => {
|
|
48
|
-
const img = /* @__PURE__ */ jsxRuntime.jsx("img", { src: node.url, alt: node.alt ?? void 0, "data-copyright": node.copyright ? node.copyright : void 0 });
|
|
49
|
-
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "block-img", children: node.linkTo ? /* @__PURE__ */ jsxRuntime.jsx(PrismicLink.PrismicLink, { linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, field: node.linkTo, children: img }) : img }, key);
|
|
50
|
-
},
|
|
51
|
-
embed: ({ node, key }) => /* @__PURE__ */ jsxRuntime.jsx("div", { "data-oembed": node.oembed.embed_url, "data-oembed-type": node.oembed.type, "data-oembed-provider": node.oembed.provider_name, dangerouslySetInnerHTML: { __html: node.oembed.html ?? "" } }, key),
|
|
52
|
-
hyperlink: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx(PrismicLink.PrismicLink, { field: node.data, linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, children }, key),
|
|
53
|
-
label: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: node.data.label, children }, key),
|
|
54
|
-
span: ({ text, key }) => {
|
|
55
|
-
const result = [];
|
|
56
|
-
let i = 0;
|
|
57
|
-
for (const line of text.split("\n")) {
|
|
58
|
-
if (i > 0) {
|
|
59
|
-
result.push(/* @__PURE__ */ jsxRuntime.jsx("br", {}, `${i}__break`));
|
|
60
|
-
}
|
|
61
|
-
result.push(/* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: line }, `${i}__line`));
|
|
62
|
-
i++;
|
|
63
|
-
}
|
|
64
|
-
return /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: result }, key);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
function PrismicRichText({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, ...restProps }) {
|
|
68
|
-
return React__namespace.useMemo(() => {
|
|
69
|
-
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
70
|
-
if ("className" in restProps) {
|
|
71
|
-
console.warn(`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg.devMsg("classname-is-not-a-valid-prop")}.`, field);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (isFilled.richText(field)) {
|
|
75
|
-
const serializer = prismicR__namespace.composeSerializers(typeof components === "object" ? prismicR__namespace.wrapMapSerializer(components) : components, createDefaultSerializer({
|
|
76
|
-
linkResolver,
|
|
77
|
-
internalLinkComponent,
|
|
78
|
-
externalLinkComponent
|
|
79
|
-
}));
|
|
80
|
-
const serialized = prismicR__namespace.serialize(field, (type, node, text, children, key) => {
|
|
81
|
-
const result = serializer(type, node, text, children, key);
|
|
82
|
-
if (React__namespace.isValidElement(result) && result.key == null) {
|
|
83
|
-
return React__namespace.cloneElement(result, { key });
|
|
84
|
-
} else {
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: serialized });
|
|
89
|
-
} else {
|
|
90
|
-
return fallback != null ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback }) : null;
|
|
91
|
-
}
|
|
92
|
-
}, [
|
|
93
|
-
field,
|
|
94
|
-
internalLinkComponent,
|
|
95
|
-
externalLinkComponent,
|
|
96
|
-
components,
|
|
97
|
-
linkResolver,
|
|
98
|
-
fallback
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
exports.PrismicRichText = PrismicRichText;
|
|
102
|
-
//# sourceMappingURL=PrismicRichText.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.cjs","sources":["../../../src/react-server/PrismicRichText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport * as prismicR from \"@prismicio/richtext\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"../types\";\nimport { LinkProps, PrismicLink } from \"./PrismicLink\";\nimport { devMsg } from \"../lib/devMsg\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a Rich Text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\ntype CreateDefaultSerializerArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n};\n\nconst getDir = (node: prismicT.RTAnyNode): \"rtl\" | undefined => {\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\treturn \"rtl\";\n\t}\n};\n\nconst createDefaultSerializer = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(\n\targs: CreateDefaultSerializerArgs<LinkResolverFunction>,\n): JSXFunctionSerializer =>\n\tprismicR.wrapMapSerializer({\n\t\theading1: ({ node, children, key }) => (\n\t\t\t<h1 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h1>\n\t\t),\n\t\theading2: ({ node, children, key }) => (\n\t\t\t<h2 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h2>\n\t\t),\n\t\theading3: ({ node, children, key }) => (\n\t\t\t<h3 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h3>\n\t\t),\n\t\theading4: ({ node, children, key }) => (\n\t\t\t<h4 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h4>\n\t\t),\n\t\theading5: ({ node, children, key }) => (\n\t\t\t<h5 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h5>\n\t\t),\n\t\theading6: ({ node, children, key }) => (\n\t\t\t<h6 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h6>\n\t\t),\n\t\tparagraph: ({ node, children, key }) => (\n\t\t\t<p key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t),\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\toListItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: React.ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <React.Fragment key={key}>{result}</React.Fragment>;\n\t\t},\n\t});\n\n/**\n * React component that renders content from a Prismic Rich Text field. By\n * default, HTML elements are rendered for each piece of content. A `heading1`\n * block will render an `<h1>` HTML element, for example. Links will use\n * `<PrismicLink>` by default which can be customized using the\n * `internalLinkComponent` and `externalLinkComponent` props.\n *\n * To customize the components that are rendered, provide a map or function\n * serializer to the `components` prop.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicRichText>`.\n * @example Rendering a Rich Text field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicRichText field={document.data.content} />;\n * ```\n *\n * @example Rendering a Rich Text field using a custom set of React components.\n *\n * ```jsx\n * <PrismicRichText\n * \tfield={document.data.content}\n * \tcomponents={{\n * \t\theading1: ({ children }) => <Heading>{children}</Heading>,\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as React components.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}\n */\nexport function PrismicRichText<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tlinkResolver,\n\tfield,\n\tfallback,\n\tcomponents,\n\texternalLinkComponent,\n\tinternalLinkComponent,\n\t...restProps\n}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {\n\treturn React.useMemo(() => {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tprocess.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (\"className\" in restProps) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t\t)}.`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (prismic.isFilled.richText(field)) {\n\t\t\tconst serializer = prismicR.composeSerializers(\n\t\t\t\ttypeof components === \"object\"\n\t\t\t\t\t? prismicR.wrapMapSerializer(components)\n\t\t\t\t\t: components,\n\t\t\t\tcreateDefaultSerializer({\n\t\t\t\t\tlinkResolver,\n\t\t\t\t\tinternalLinkComponent,\n\t\t\t\t\texternalLinkComponent,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// The serializer is wrapped in a higher-order function\n\t\t\t// that automatically applies a key to React Elements\n\t\t\t// if one is not already given.\n\t\t\tconst serialized = prismicR.serialize<JSX.Element>(\n\t\t\t\tfield,\n\t\t\t\t(type, node, text, children, key) => {\n\t\t\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\t\t\tif (React.isValidElement(result) && result.key == null) {\n\t\t\t\t\t\treturn React.cloneElement(result, { key });\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn <>{serialized}</>;\n\t\t} else {\n\t\t\treturn fallback != null ? <>{fallback}</> : null;\n\t\t}\n\t}, [\n\t\tfield,\n\t\tinternalLinkComponent,\n\t\texternalLinkComponent,\n\t\tcomponents,\n\t\tlinkResolver,\n\t\tfallback,\n\t]);\n}\n"],"names":["prismicR","jsx","PrismicLink","React","devMsg","prismic.isFilled.richText","Fragment"],"mappings":";;;;;;;;;;;;;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AAAA,QAAA,OACnC;AACC,iBAAA;AAAA,QACP;AAAA,MAAA,CACD;AAGF,mEAAU,UAAW,WAAA,CAAA;AAAA,IAAA,OACf;AACN,aAAO,YAAY,OAAUF,+BAAAK,WAAAA,UAAA,EAAA,UAAA,UAAS,IAAM;AAAA,IAC5C;AAAA,EAAA,GACC;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;;"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as prismic from "@prismicio/client";
|
|
3
|
-
import { JSXFunctionSerializer, JSXMapSerializer } from "../types";
|
|
4
|
-
import { LinkProps } from "./PrismicLink";
|
|
5
|
-
/**
|
|
6
|
-
* Props for `<PrismicRichText>`.
|
|
7
|
-
*/
|
|
8
|
-
export type PrismicRichTextProps<LinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction> = {
|
|
9
|
-
/**
|
|
10
|
-
* The Prismic Rich Text field to render.
|
|
11
|
-
*/
|
|
12
|
-
field: prismic.RichTextField | null | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* The Link Resolver used to resolve links.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* If your app uses Route Resolvers when querying for your Prismic
|
|
18
|
-
* repository's content, a Link Resolver does not need to be provided.
|
|
19
|
-
* @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
20
|
-
*/
|
|
21
|
-
linkResolver?: LinkResolverFunction;
|
|
22
|
-
/**
|
|
23
|
-
* A map or function that maps a Rich Text block to a React component.
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* Prefer using a map serializer over the function serializer when possible.
|
|
27
|
-
* The map serializer is simpler to maintain.
|
|
28
|
-
* @example A map serializer.
|
|
29
|
-
*
|
|
30
|
-
* ```jsx
|
|
31
|
-
* {
|
|
32
|
-
* heading1: ({children}) => <Heading>{children}</Heading>
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @example A function serializer.
|
|
37
|
-
*
|
|
38
|
-
* ```jsx
|
|
39
|
-
* (type, node, content, children) => {
|
|
40
|
-
* switch (type) {
|
|
41
|
-
* case "heading1": {
|
|
42
|
-
* return <Heading>{children}</Heading>;
|
|
43
|
-
* }
|
|
44
|
-
* }
|
|
45
|
-
* };
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
components?: JSXMapSerializer | JSXFunctionSerializer;
|
|
49
|
-
/**
|
|
50
|
-
* The React component rendered for links when the URL is internal.
|
|
51
|
-
*
|
|
52
|
-
* @defaultValue `<a>`
|
|
53
|
-
*/
|
|
54
|
-
internalLinkComponent?: React.ComponentType<LinkProps>;
|
|
55
|
-
/**
|
|
56
|
-
* The React component rendered for links when the URL is external.
|
|
57
|
-
*
|
|
58
|
-
* @defaultValue `<a>`
|
|
59
|
-
*/
|
|
60
|
-
externalLinkComponent?: React.ComponentType<LinkProps>;
|
|
61
|
-
/**
|
|
62
|
-
* The value to be rendered when the field is empty. If a fallback is not
|
|
63
|
-
* given, `null` will be rendered.
|
|
64
|
-
*/
|
|
65
|
-
fallback?: React.ReactNode;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* React component that renders content from a Prismic Rich Text field. By
|
|
69
|
-
* default, HTML elements are rendered for each piece of content. A `heading1`
|
|
70
|
-
* block will render an `<h1>` HTML element, for example. Links will use
|
|
71
|
-
* `<PrismicLink>` by default which can be customized using the
|
|
72
|
-
* `internalLinkComponent` and `externalLinkComponent` props.
|
|
73
|
-
*
|
|
74
|
-
* To customize the components that are rendered, provide a map or function
|
|
75
|
-
* serializer to the `components` prop.
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* This component returns a React fragment with no wrapping element around the
|
|
79
|
-
* content. If you need a wrapper, add a component around `<PrismicRichText>`.
|
|
80
|
-
* @example Rendering a Rich Text field using the default HTMl elements.
|
|
81
|
-
*
|
|
82
|
-
* ```jsx
|
|
83
|
-
* <PrismicRichText field={document.data.content} />;
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @example Rendering a Rich Text field using a custom set of React components.
|
|
87
|
-
*
|
|
88
|
-
* ```jsx
|
|
89
|
-
* <PrismicRichText
|
|
90
|
-
* field={document.data.content}
|
|
91
|
-
* components={{
|
|
92
|
-
* heading1: ({ children }) => <Heading>{children}</Heading>,
|
|
93
|
-
* }}
|
|
94
|
-
* />;
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @param props - Props for the component.
|
|
98
|
-
*
|
|
99
|
-
* @returns The Rich Text field's content as React components.
|
|
100
|
-
*
|
|
101
|
-
* @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
|
|
102
|
-
* @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
103
|
-
*/
|
|
104
|
-
export declare function PrismicRichText<LinkResolverFunction extends prismic.LinkResolverFunction<any>>({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, ...restProps }: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import * as prismicR from "@prismicio/richtext";
|
|
4
|
-
import { PrismicLink } from "./PrismicLink.js";
|
|
5
|
-
import { devMsg } from "../lib/devMsg.js";
|
|
6
|
-
import { richText } from './../_node_modules/@prismicio/client/dist/helpers/isFilled.js';
|
|
7
|
-
const getDir = (node) => {
|
|
8
|
-
if ("direction" in node && node.direction === "rtl") {
|
|
9
|
-
return "rtl";
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const createDefaultSerializer = (args) => prismicR.wrapMapSerializer({
|
|
13
|
-
heading1: ({ node, children, key }) => /* @__PURE__ */ jsx("h1", { dir: getDir(node), children }, key),
|
|
14
|
-
heading2: ({ node, children, key }) => /* @__PURE__ */ jsx("h2", { dir: getDir(node), children }, key),
|
|
15
|
-
heading3: ({ node, children, key }) => /* @__PURE__ */ jsx("h3", { dir: getDir(node), children }, key),
|
|
16
|
-
heading4: ({ node, children, key }) => /* @__PURE__ */ jsx("h4", { dir: getDir(node), children }, key),
|
|
17
|
-
heading5: ({ node, children, key }) => /* @__PURE__ */ jsx("h5", { dir: getDir(node), children }, key),
|
|
18
|
-
heading6: ({ node, children, key }) => /* @__PURE__ */ jsx("h6", { dir: getDir(node), children }, key),
|
|
19
|
-
paragraph: ({ node, children, key }) => /* @__PURE__ */ jsx("p", { dir: getDir(node), children }, key),
|
|
20
|
-
preformatted: ({ node, key }) => /* @__PURE__ */ jsx("pre", { children: node.text }, key),
|
|
21
|
-
strong: ({ children, key }) => /* @__PURE__ */ jsx("strong", { children }, key),
|
|
22
|
-
em: ({ children, key }) => /* @__PURE__ */ jsx("em", { children }, key),
|
|
23
|
-
listItem: ({ node, children, key }) => /* @__PURE__ */ jsx("li", { dir: getDir(node), children }, key),
|
|
24
|
-
oListItem: ({ node, children, key }) => /* @__PURE__ */ jsx("li", { dir: getDir(node), children }, key),
|
|
25
|
-
list: ({ children, key }) => /* @__PURE__ */ jsx("ul", { children }, key),
|
|
26
|
-
oList: ({ children, key }) => /* @__PURE__ */ jsx("ol", { children }, key),
|
|
27
|
-
image: ({ node, key }) => {
|
|
28
|
-
const img = /* @__PURE__ */ jsx("img", { src: node.url, alt: node.alt ?? void 0, "data-copyright": node.copyright ? node.copyright : void 0 });
|
|
29
|
-
return /* @__PURE__ */ jsx("p", { className: "block-img", children: node.linkTo ? /* @__PURE__ */ jsx(PrismicLink, { linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, field: node.linkTo, children: img }) : img }, key);
|
|
30
|
-
},
|
|
31
|
-
embed: ({ node, key }) => /* @__PURE__ */ jsx("div", { "data-oembed": node.oembed.embed_url, "data-oembed-type": node.oembed.type, "data-oembed-provider": node.oembed.provider_name, dangerouslySetInnerHTML: { __html: node.oembed.html ?? "" } }, key),
|
|
32
|
-
hyperlink: ({ node, children, key }) => /* @__PURE__ */ jsx(PrismicLink, { field: node.data, linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, children }, key),
|
|
33
|
-
label: ({ node, children, key }) => /* @__PURE__ */ jsx("span", { className: node.data.label, children }, key),
|
|
34
|
-
span: ({ text, key }) => {
|
|
35
|
-
const result = [];
|
|
36
|
-
let i = 0;
|
|
37
|
-
for (const line of text.split("\n")) {
|
|
38
|
-
if (i > 0) {
|
|
39
|
-
result.push(/* @__PURE__ */ jsx("br", {}, `${i}__break`));
|
|
40
|
-
}
|
|
41
|
-
result.push(/* @__PURE__ */ jsx(React.Fragment, { children: line }, `${i}__line`));
|
|
42
|
-
i++;
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ jsx(React.Fragment, { children: result }, key);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
function PrismicRichText({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, ...restProps }) {
|
|
48
|
-
return React.useMemo(() => {
|
|
49
|
-
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
50
|
-
if ("className" in restProps) {
|
|
51
|
-
console.warn(`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg("classname-is-not-a-valid-prop")}.`, field);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (richText(field)) {
|
|
55
|
-
const serializer = prismicR.composeSerializers(typeof components === "object" ? prismicR.wrapMapSerializer(components) : components, createDefaultSerializer({
|
|
56
|
-
linkResolver,
|
|
57
|
-
internalLinkComponent,
|
|
58
|
-
externalLinkComponent
|
|
59
|
-
}));
|
|
60
|
-
const serialized = prismicR.serialize(field, (type, node, text, children, key) => {
|
|
61
|
-
const result = serializer(type, node, text, children, key);
|
|
62
|
-
if (React.isValidElement(result) && result.key == null) {
|
|
63
|
-
return React.cloneElement(result, { key });
|
|
64
|
-
} else {
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return /* @__PURE__ */ jsx(Fragment, { children: serialized });
|
|
69
|
-
} else {
|
|
70
|
-
return fallback != null ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
|
|
71
|
-
}
|
|
72
|
-
}, [
|
|
73
|
-
field,
|
|
74
|
-
internalLinkComponent,
|
|
75
|
-
externalLinkComponent,
|
|
76
|
-
components,
|
|
77
|
-
linkResolver,
|
|
78
|
-
fallback
|
|
79
|
-
]);
|
|
80
|
-
}
|
|
81
|
-
export {
|
|
82
|
-
PrismicRichText
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=PrismicRichText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.js","sources":["../../../src/react-server/PrismicRichText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport * as prismicR from \"@prismicio/richtext\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"../types\";\nimport { LinkProps, PrismicLink } from \"./PrismicLink\";\nimport { devMsg } from \"../lib/devMsg\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a Rich Text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\ntype CreateDefaultSerializerArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n};\n\nconst getDir = (node: prismicT.RTAnyNode): \"rtl\" | undefined => {\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\treturn \"rtl\";\n\t}\n};\n\nconst createDefaultSerializer = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(\n\targs: CreateDefaultSerializerArgs<LinkResolverFunction>,\n): JSXFunctionSerializer =>\n\tprismicR.wrapMapSerializer({\n\t\theading1: ({ node, children, key }) => (\n\t\t\t<h1 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h1>\n\t\t),\n\t\theading2: ({ node, children, key }) => (\n\t\t\t<h2 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h2>\n\t\t),\n\t\theading3: ({ node, children, key }) => (\n\t\t\t<h3 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h3>\n\t\t),\n\t\theading4: ({ node, children, key }) => (\n\t\t\t<h4 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h4>\n\t\t),\n\t\theading5: ({ node, children, key }) => (\n\t\t\t<h5 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h5>\n\t\t),\n\t\theading6: ({ node, children, key }) => (\n\t\t\t<h6 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h6>\n\t\t),\n\t\tparagraph: ({ node, children, key }) => (\n\t\t\t<p key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t),\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\toListItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: React.ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <React.Fragment key={key}>{result}</React.Fragment>;\n\t\t},\n\t});\n\n/**\n * React component that renders content from a Prismic Rich Text field. By\n * default, HTML elements are rendered for each piece of content. A `heading1`\n * block will render an `<h1>` HTML element, for example. Links will use\n * `<PrismicLink>` by default which can be customized using the\n * `internalLinkComponent` and `externalLinkComponent` props.\n *\n * To customize the components that are rendered, provide a map or function\n * serializer to the `components` prop.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicRichText>`.\n * @example Rendering a Rich Text field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicRichText field={document.data.content} />;\n * ```\n *\n * @example Rendering a Rich Text field using a custom set of React components.\n *\n * ```jsx\n * <PrismicRichText\n * \tfield={document.data.content}\n * \tcomponents={{\n * \t\theading1: ({ children }) => <Heading>{children}</Heading>,\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as React components.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}\n */\nexport function PrismicRichText<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tlinkResolver,\n\tfield,\n\tfallback,\n\tcomponents,\n\texternalLinkComponent,\n\tinternalLinkComponent,\n\t...restProps\n}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {\n\treturn React.useMemo(() => {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tprocess.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (\"className\" in restProps) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t\t)}.`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (prismic.isFilled.richText(field)) {\n\t\t\tconst serializer = prismicR.composeSerializers(\n\t\t\t\ttypeof components === \"object\"\n\t\t\t\t\t? prismicR.wrapMapSerializer(components)\n\t\t\t\t\t: components,\n\t\t\t\tcreateDefaultSerializer({\n\t\t\t\t\tlinkResolver,\n\t\t\t\t\tinternalLinkComponent,\n\t\t\t\t\texternalLinkComponent,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// The serializer is wrapped in a higher-order function\n\t\t\t// that automatically applies a key to React Elements\n\t\t\t// if one is not already given.\n\t\t\tconst serialized = prismicR.serialize<JSX.Element>(\n\t\t\t\tfield,\n\t\t\t\t(type, node, text, children, key) => {\n\t\t\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\t\t\tif (React.isValidElement(result) && result.key == null) {\n\t\t\t\t\t\treturn React.cloneElement(result, { key });\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn <>{serialized}</>;\n\t\t} else {\n\t\t\treturn fallback != null ? <>{fallback}</> : null;\n\t\t}\n\t}, [\n\t\tfield,\n\t\tinternalLinkComponent,\n\t\texternalLinkComponent,\n\t\tcomponents,\n\t\tlinkResolver,\n\t\tfallback,\n\t]);\n}\n"],"names":["prismic.isFilled.richText"],"mappings":";;;;;;AAyFA,MAAM,SAAS,CAAC,SAA+C;AAC9D,MAAI,eAAe,QAAQ,KAAK,cAAc,OAAO;AAC7C,WAAA;AAAA,EACP;AACF;AAEA,MAAM,0BAA0B,CAI/B,SAEA,SAAS,kBAAkB;AAAA,EAC1B,UAAU,CAAC,EAAE,MAAM,UAAU,IAAK,MAChC,oBAAA,MAAA,EAAa,KAAK,OAAO,IAAI,GAC5B,YADO,GAET;AAAA,EAED,UAAU,CAAC,EAAE,MAAM,UAAU,IAAK,MAChC,oBAAA,MAAA,EA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ACA,CAAA;AAuCc,SAAA,gBAGd,EACD,cACA,OACA,UACA,YACA,uBACA,uBACA,GAAG,aACyC;AACrC,SAAA,MAAM,QAAQ,MAAK;AACzB,QACC,OAAO,YAAY,eACnB,QAAQ,IAAI,aAAa,eACxB;AACD,UAAI,eAAe,WAAW;AAC7B,gBAAQ,KACP,mJAAmJ,OAClJ,+BAA+B,MAEhC,KAAK;AAAA,MAEN;AAAA,IACD;AAED,QAAIA,SAA0B,KAAK,GAAG;AAC/B,YAAA,aAAa,SAAS,mBAC3B,OAAO,eAAe,WACnB,SAAS,kBAAkB,UAAU,IACrC,YACH,wBAAwB;AAAA,QACvB;AAAA,QACA;AAAA,QACA;AAAA,MACA,CAAA,CAAC;AAMG,YAAA,aAAa,SAAS,UAC3B,OACA,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AACnC,cAAM,SAAS,WAAW,MAAM,MAAM,MAAM,UAAU,GAAG;AAEzD,YAAI,MAAM,eAAe,MAAM,KAAK,OAAO,OAAO,MAAM;AACvD,iBAAO,MAAM,aAAa,QAAQ,EAAE,IAAK,CAAA;AAAA,QAAA,OACnC;AACC,iBAAA;AAAA,QACP;AAAA,MAAA,CACD;AAGF,6CAAU,UAAW,WAAA,CAAA;AAAA,IAAA,OACf;AACN,aAAO,YAAY,OAAU,oBAAA,UAAA,EAAA,UAAA,UAAS,IAAM;AAAA,IAC5C;AAAA,EAAA,GACC;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { PrismicLink } from "./PrismicLink";
|
|
2
|
-
export { PrismicRichText } from "./PrismicRichText";
|
|
3
|
-
export { PrismicProvider, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useAllPrismicDocumentsDangerously, useFirstPrismicDocument, usePrismicClient, usePrismicContext, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicPreviewResolver, useSinglePrismicDocument, } from "./unsupported";
|
|
4
|
-
export { Element, PrismicImage, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent, } from "..";
|