@prismicio/client 7.0.0-alpha.3 → 7.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/createClient.cjs +57 -76
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +61 -69
- package/dist/createClient.js +57 -76
- package/dist/createClient.js.map +1 -1
- package/dist/helpers/asHTML.cjs +17 -4
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.ts +55 -13
- package/dist/helpers/asHTML.js +17 -4
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +2 -2
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -2
- package/dist/helpers/asImagePixelDensitySrcSet.js +2 -2
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +2 -2
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +2 -2
- package/dist/helpers/asImageSrc.js +2 -2
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +2 -2
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +2 -2
- package/dist/helpers/asImageWidthSrcSet.js +2 -2
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs +12 -3
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.ts +55 -15
- package/dist/helpers/asLink.js +12 -3
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asText.cjs +11 -2
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.ts +44 -10
- package/dist/helpers/asText.js +11 -2
- package/dist/helpers/asText.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/src/createClient.ts +176 -251
- package/src/helpers/asHTML.ts +98 -25
- package/src/helpers/asImagePixelDensitySrcSet.ts +3 -3
- package/src/helpers/asImageSrc.ts +3 -3
- package/src/helpers/asImageWidthSrcSet.ts +3 -3
- package/src/helpers/asLink.ts +102 -18
- package/src/helpers/asText.ts +71 -12
package/dist/helpers/asText.d.ts
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
1
1
|
import { RichTextField } from "../types/value/richText";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Configuration that determines the output of `asText()`.
|
|
4
4
|
*/
|
|
5
|
-
type
|
|
5
|
+
type AsTextConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* Separator used to join each element.
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue ` ` (a space)
|
|
10
|
+
*/
|
|
11
|
+
separator?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use object-style configuration instead.
|
|
15
|
+
*/
|
|
16
|
+
type AsTextDeprecatedTupleConfig = [separator?: string];
|
|
6
17
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param richTextField - A Rich Text or Title field from Prismic
|
|
10
|
-
* @param separator - Separator used to join each element, defaults to a space
|
|
11
|
-
*
|
|
12
|
-
* @returns Plain text equivalent of the provided Rich Text or Title field
|
|
13
|
-
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
|
|
18
|
+
* The return type of `asText()`.
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
type AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField ? string : null;
|
|
21
|
+
export declare const asText: {
|
|
22
|
+
/**
|
|
23
|
+
* Serializes a Rich Text or Title field to a plain text string.
|
|
24
|
+
*
|
|
25
|
+
* @param richTextField - A Rich Text or Title field from Prismic
|
|
26
|
+
* @param config - Configuration that determines the output of `asText()`
|
|
27
|
+
*
|
|
28
|
+
* @returns Plain text equivalent of the provided Rich Text or Title field
|
|
29
|
+
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
|
|
30
|
+
*/
|
|
31
|
+
<Field extends RichTextField | null | undefined>(richTextField: Field, config?: AsTextConfig): AsTextReturnType<Field>;
|
|
32
|
+
/**
|
|
33
|
+
* Serializes a Rich Text or Title field to a plain text string.
|
|
34
|
+
*
|
|
35
|
+
* @param richTextField - A Rich Text or Title field from Prismic
|
|
36
|
+
* @param separator - Separator used to join each element, defaults to a space
|
|
37
|
+
*
|
|
38
|
+
* @returns Plain text equivalent of the provided Rich Text or Title field
|
|
39
|
+
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
|
|
40
|
+
*
|
|
41
|
+
* @deprecated Use object-style configuration instead.
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* asText(field);
|
|
45
|
+
* asText(field, { separator });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
<Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsTextDeprecatedTupleConfig): AsTextReturnType<Field>;
|
|
49
|
+
};
|
|
16
50
|
export {};
|
package/dist/helpers/asText.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { asText as asText$1 } from "@prismicio/richtext";
|
|
2
|
-
const asText = (richTextField,
|
|
2
|
+
const asText = (richTextField, ...configObjectOrTuple) => {
|
|
3
3
|
if (richTextField) {
|
|
4
|
-
|
|
4
|
+
const [configObjectOrSeparator] = configObjectOrTuple;
|
|
5
|
+
let config;
|
|
6
|
+
if (typeof configObjectOrSeparator === "string") {
|
|
7
|
+
config = {
|
|
8
|
+
separator: configObjectOrSeparator
|
|
9
|
+
};
|
|
10
|
+
} else {
|
|
11
|
+
config = { ...configObjectOrSeparator };
|
|
12
|
+
}
|
|
13
|
+
return asText$1(richTextField, config.separator);
|
|
5
14
|
} else {
|
|
6
15
|
return null;
|
|
7
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.js","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"@prismicio/richtext\";\n\nimport { RichTextField } from \"../types/value/richText\";\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\n/**\n * Serializes a Rich Text or Title field to a plain text string\n *\n * @param richTextField - A Rich Text or Title field from Prismic\n * @param separator - Separator used to join each element, defaults to a space\n *\n * @returns Plain text equivalent of the provided Rich Text or Title field\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n
|
|
1
|
+
{"version":3,"file":"asText.js","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"@prismicio/richtext\";\n\nimport { RichTextField } from \"../types/value/richText\";\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string];\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\nexport const asText: {\n\t/**\n\t * Serializes a Rich Text or Title field to a plain text string.\n\t *\n\t * @param richTextField - A Rich Text or Title field from Prismic\n\t * @param config - Configuration that determines the output of `asText()`\n\t *\n\t * @returns Plain text equivalent of the provided Rich Text or Title field\n\t * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>;\n\n\t/**\n\t * Serializes a Rich Text or Title field to a plain text string.\n\t *\n\t * @param richTextField - A Rich Text or Title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text equivalent of the provided Rich Text or Title field\n\t * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asText(field);\n\t * asText(field, { separator });\n\t * ```\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>;\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple;\n\t\tlet config: AsTextConfig;\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator };\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>;\n\t} else {\n\t\treturn null as AsTextReturnType<Field>;\n\t}\n};\n"],"names":["baseAsText"],"mappings":";AA4Ba,MAAA,SAmCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA,MAAA;AAAA,WAEN;AACG,eAAA,EAAE,GAAG;IACd;AAEM,WAAAA,SACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EACP;AACF;"}
|
package/dist/package.json.cjs
CHANGED
package/dist/package.json.js
CHANGED