@madebywild/sanity-richtext-field 3.0.0 → 3.1.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.
package/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  Rich text field plugin with configurable blocks, marks, and presets.
7
7
 
8
-
9
8
  ## Install
10
9
 
11
10
  ```bash
@@ -15,65 +14,29 @@ pnpm add @madebywild/sanity-richtext-field
15
14
  ## Configure Plugin
16
15
 
17
16
  ```ts
17
+ import { defineConfig, defineField } from "sanity";
18
18
  import { wildSanityRichtextFieldPlugin } from "@madebywild/sanity-richtext-field";
19
- import {
20
- createAnnotations,
21
- createDecorators,
22
- createLists,
23
- createSpans,
24
- createStyles,
25
- } from "@madebywild/sanity-richtext-field/parts";
26
- import { createBlock as quoteBlock } from "@madebywild/sanity-richtext-field/blocks/quote-block";
27
19
  import { createBlock } from "@madebywild/sanity-richtext-field/utils";
20
+ import { createBlock as quoteBlock } from "@madebywild/sanity-richtext-field/blocks/quote-block";
21
+ import { createAnnotations, createDecorators, createLists, createSpans, createStyles } from "@madebywild/sanity-richtext-field/parts";
28
22
 
29
23
  const customBlock = defineField({
30
- name: "customBlockTest",
24
+ name: "customBlock",
31
25
  type: "object",
32
- fields: [
33
- defineField({
34
- name: "title",
35
- type: "string",
36
- title: "Title",
37
- }),
38
- ],
26
+ title: "Custom Block",
27
+ fields: [defineField({ name: "title", type: "string" })],
39
28
  });
40
29
 
41
30
  export default defineConfig({
42
31
  plugins: [
43
32
  wildSanityRichtextFieldPlugin({
33
+ spellCheck: true,
44
34
  blocks: [createBlock(customBlock), quoteBlock()],
45
- spans: [...createSpans() /* Add your own */],
46
- styles: [...createStyles() /* Add your own */],
47
- lists: [...createLists() /* Add your own */],
48
- decorators: [...createDecorators() /* Add your own */],
49
- annotations: [...createAnnotations() /* Add your own */],
50
- }),
51
- ],
52
- });
53
- ```
54
-
55
- ```ts
56
- // Override built-in annotation rendering (color/highlight)
57
- wildSanityRichtextFieldPlugin({
58
- annotations: [
59
- ...createAnnotations({
60
- textColor: {
61
- renderValue: (value, props) => (
62
- <span style={{ color: getColor(value)?.cssVar }}>{props.renderDefault(props)}</span>
63
- ),
64
- },
65
- highlightColor: {
66
- renderValue: (value, props) => (
67
- <mark style={{ backgroundColor: getColor(value)?.cssVar }}>{props.renderDefault(props)}</mark>
68
- ),
69
- },
70
- }),
71
- ],
72
- spans: [
73
- ...createSpans({
74
- icon: {
75
- renderValue: (value) => <Icon name={value as IconName} />,
76
- },
35
+ spans: [...createSpans()],
36
+ styles: [...createStyles()],
37
+ lists: [...createLists()],
38
+ decorators: [...createDecorators()],
39
+ annotations: [...createAnnotations()],
77
40
  }),
78
41
  ],
79
42
  });
@@ -82,18 +45,19 @@ wildSanityRichtextFieldPlugin({
82
45
  ## Use in Schema
83
46
 
84
47
  ```ts
48
+ import { defineField } from "sanity";
49
+
85
50
  defineField({
86
51
  name: "body",
87
52
  type: "wild.richtext",
88
53
  options: {
89
- // Presets are collections of options that can be used to configure the field.
90
- preset: "full",
91
- // Whitelist / Blacklist features.
92
- // By default, the field comes with NO features enabled.
93
- allowedKinds: ["styles", "lists", "decorators", "annotations"],
94
- allowedParts: ["wild.richtext.annotations.bold"],
95
- disallowedKinds: ["styles", "lists", "decorators", "annotations"],
96
- disallowedParts: ["wild.richtext.annotations.bold"],
54
+ size: "lg", // "sm" | "lg" | custom height string (e.g. "480px")
55
+ preset: "full", // "basic" | "full"
56
+ initiallyActive: false,
57
+ allowedKinds: ["styles", "lists", "decorators", "annotations", "spans", "blocks"],
58
+ disallowedKinds: ["annotations"],
59
+ allowedParts: ["wild.richtext.decorator.strong", "wild.richtext.annotation.link"],
60
+ disallowedParts: ["wild.richtext.decorator.underline"],
97
61
  },
98
62
  });
99
63
  ```
@@ -1,4 +1,4 @@
1
- import * as sanity65 from "sanity";
1
+ import * as sanity64 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  import { FieldOptions } from "@madebywild/sanity-media-field";
4
4
  type Options = Omit<Partial<ObjectDefinition>, "type"> & {
@@ -16,9 +16,9 @@ declare function createBlock({
16
16
  }?: Options): {
17
17
  type: "object";
18
18
  name?: string | undefined;
19
- } & Omit<sanity65.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity65.PreviewConfig<{
19
+ } & Omit<sanity64.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity64.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity65.WidenValidation & sanity65.WidenInitialValue;
23
+ } & sanity64.WidenValidation & sanity64.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity72 from "sanity";
1
+ import * as sanity73 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  import { FieldOptions } from "@madebywild/sanity-media-field";
4
4
  type Options = Omit<Partial<ObjectDefinition>, "type"> & {
@@ -16,9 +16,9 @@ declare function createBlock({
16
16
  }?: Options): {
17
17
  type: "object";
18
18
  name?: string | undefined;
19
- } & Omit<sanity72.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity72.PreviewConfig<{
19
+ } & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity73.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity72.WidenValidation & sanity72.WidenInitialValue;
23
+ } & sanity73.WidenValidation & sanity73.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity73 from "sanity";
1
+ import * as sanity72 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  import { FieldOptions } from "@madebywild/sanity-media-field";
4
4
  type Options = Omit<Partial<ObjectDefinition>, "type"> & {
@@ -16,9 +16,9 @@ declare function createBlock({
16
16
  }?: Options): {
17
17
  type: "object";
18
18
  name?: string | undefined;
19
- } & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity73.PreviewConfig<{
19
+ } & Omit<sanity72.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity72.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity73.WidenValidation & sanity73.WidenInitialValue;
23
+ } & sanity72.WidenValidation & sanity72.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity60 from "sanity";
1
+ import * as sanity69 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  import { FieldOptions } from "@madebywild/sanity-media-field";
4
4
  type Options = Omit<Partial<ObjectDefinition>, "type"> & {
@@ -16,9 +16,9 @@ declare function createBlock({
16
16
  }?: Options): {
17
17
  type: "object";
18
18
  name?: string | undefined;
19
- } & Omit<sanity60.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity60.PreviewConfig<{
19
+ } & Omit<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity69.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity60.WidenValidation & sanity60.WidenInitialValue;
23
+ } & sanity69.WidenValidation & sanity69.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity61 from "sanity";
1
+ import * as sanity68 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  import { FieldOptions } from "@madebywild/sanity-media-field";
4
4
  type Options = Omit<Partial<ObjectDefinition>, "type"> & {
@@ -16,9 +16,9 @@ declare function createBlock({
16
16
  }?: Options): {
17
17
  type: "object";
18
18
  name?: string | undefined;
19
- } & Omit<sanity61.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity61.PreviewConfig<{
19
+ } & Omit<sanity68.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity68.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity61.WidenValidation & sanity61.WidenInitialValue;
23
+ } & sanity68.WidenValidation & sanity68.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity64 from "sanity";
1
+ import * as sanity65 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  import { FieldOptions } from "@madebywild/sanity-media-field";
4
4
  type Options = Omit<Partial<ObjectDefinition>, "type"> & {
@@ -16,9 +16,9 @@ declare function createBlock({
16
16
  }?: Options): {
17
17
  type: "object";
18
18
  name?: string | undefined;
19
- } & Omit<sanity64.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity64.PreviewConfig<{
19
+ } & Omit<sanity65.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity65.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity64.WidenValidation & sanity64.WidenInitialValue;
23
+ } & sanity65.WidenValidation & sanity65.WidenInitialValue;
24
24
  export { createBlock };
@@ -30,7 +30,7 @@ function createBlock({
30
30
  quote
31
31
  }) {
32
32
  return {
33
- subtitle: quote ? sanityUtils.createExcerptFromPortableText(quote, 10) : void 0
33
+ subtitle: quote ? sanityUtils.createExcerptFromPortableText(quote, 35) : void 0
34
34
  };
35
35
  }
36
36
  },
@@ -1 +1 @@
1
- {"version":3,"file":"quote-block.cjs","sources":["../../src/blocks/quote-block.tsx"],"sourcesContent":["import { requireQuote } from \"@madebywild/sanity-quote-field\";\nimport { createExcerptFromPortableText } from \"@madebywild/sanity-utils\";\nimport { defineField, type ObjectDefinition } from \"sanity\";\nimport { createBlock as createBaseBlock } from \"../internal-utils\";\nimport { typeName } from \"../types\";\n\ntype Options = Omit<Partial<ObjectDefinition>, \"type\">;\n\nconst kind = \"quote\";\n\n/** @public */\nfunction createBlock({ name, fields = [], ...props }: Options = {}) {\n const field = defineField({\n type: \"object\",\n name: name ?? `${typeName}.block.${kind}`,\n title: \"Quote\",\n icon: () => <>❝❞</>,\n fields: [\n defineField({\n type: \"wild.quote\",\n name: \"quote\",\n title: \"Quote\",\n description: \"Stylized quote content.\",\n validation: (R) => requireQuote(R),\n options: {\n inline: true,\n },\n }),\n ...fields,\n ],\n preview: {\n select: {\n quote: \"quote.quote\",\n },\n prepare({ quote }) {\n return {\n subtitle: quote ? createExcerptFromPortableText(quote, 10) : undefined,\n };\n },\n },\n ...props,\n });\n\n return createBaseBlock(field);\n}\n\nexport { createBlock };\n"],"names":["kind","createBlock","name","fields","props","field","defineField","type","typeName","title","icon","jsx","Fragment","description","validation","R","requireQuote","options","inline","preview","select","quote","prepare","subtitle","createExcerptFromPortableText","undefined","createBaseBlock"],"mappings":";;;AAQA,MAAMA,OAAO;AAGb,SAASC,YAAY;AAAA,EAAEC;AAAAA,EAAMC,SAAS,CAAA;AAAA,EAAI,GAAGC;AAAe,IAAI,IAAI;AAClE,QAAMC,QAAQC,OAAAA,YAAY;AAAA,IACxBC,MAAM;AAAA,IACNL,MAAMA,QAAQ,GAAGM,MAAAA,QAAQ,UAAUR,IAAI;AAAA,IACvCS,OAAO;AAAA,IACPC,MAAMA,MAAMC,2BAAAA,IAAAC,WAAAA,UAAA,EAAE,UAAA,eAAA,CAAE;AAAA,IAChBT,QAAQ,CACNG,OAAAA,YAAY;AAAA,MACVC,MAAM;AAAA,MACNL,MAAM;AAAA,MACNO,OAAO;AAAA,MACPI,aAAa;AAAA,MACbC,YAAaC,CAAAA,MAAMC,iBAAAA,aAAaD,CAAC;AAAA,MACjCE,SAAS;AAAA,QACPC,QAAQ;AAAA,MAAA;AAAA,IACV,CACD,GACD,GAAGf,MAAM;AAAA,IAEXgB,SAAS;AAAA,MACPC,QAAQ;AAAA,QACNC,OAAO;AAAA,MAAA;AAAA,MAETC,QAAQ;AAAA,QAAED;AAAAA,MAAAA,GAAS;AACjB,eAAO;AAAA,UACLE,UAAUF,QAAQG,YAAAA,8BAA8BH,OAAO,EAAE,IAAII;AAAAA,QAAAA;AAAAA,MAEjE;AAAA,IAAA;AAAA,IAEF,GAAGrB;AAAAA,EAAAA,CACJ;AAED,SAAOsB,MAAAA,YAAgBrB,KAAK;AAC9B;;"}
1
+ {"version":3,"file":"quote-block.cjs","sources":["../../src/blocks/quote-block.tsx"],"sourcesContent":["import { requireQuote } from \"@madebywild/sanity-quote-field\";\nimport { createExcerptFromPortableText } from \"@madebywild/sanity-utils\";\nimport { defineField, type ObjectDefinition } from \"sanity\";\nimport { createBlock as createBaseBlock } from \"../internal-utils\";\nimport { typeName } from \"../types\";\n\ntype Options = Omit<Partial<ObjectDefinition>, \"type\">;\n\nconst kind = \"quote\";\n\n/** @public */\nfunction createBlock({ name, fields = [], ...props }: Options = {}) {\n const field = defineField({\n type: \"object\",\n name: name ?? `${typeName}.block.${kind}`,\n title: \"Quote\",\n icon: () => <>❝❞</>,\n fields: [\n defineField({\n type: \"wild.quote\",\n name: \"quote\",\n title: \"Quote\",\n description: \"Stylized quote content.\",\n validation: (R) => requireQuote(R),\n options: {\n inline: true,\n },\n }),\n ...fields,\n ],\n preview: {\n select: {\n quote: \"quote.quote\",\n },\n prepare({ quote }) {\n return {\n subtitle: quote ? createExcerptFromPortableText(quote, 35) : undefined,\n };\n },\n },\n ...props,\n });\n\n return createBaseBlock(field);\n}\n\nexport { createBlock };\n"],"names":["kind","createBlock","name","fields","props","field","defineField","type","typeName","title","icon","jsx","Fragment","description","validation","R","requireQuote","options","inline","preview","select","quote","prepare","subtitle","createExcerptFromPortableText","undefined","createBaseBlock"],"mappings":";;;AAQA,MAAMA,OAAO;AAGb,SAASC,YAAY;AAAA,EAAEC;AAAAA,EAAMC,SAAS,CAAA;AAAA,EAAI,GAAGC;AAAe,IAAI,IAAI;AAClE,QAAMC,QAAQC,OAAAA,YAAY;AAAA,IACxBC,MAAM;AAAA,IACNL,MAAMA,QAAQ,GAAGM,MAAAA,QAAQ,UAAUR,IAAI;AAAA,IACvCS,OAAO;AAAA,IACPC,MAAMA,MAAMC,2BAAAA,IAAAC,WAAAA,UAAA,EAAE,UAAA,eAAA,CAAE;AAAA,IAChBT,QAAQ,CACNG,OAAAA,YAAY;AAAA,MACVC,MAAM;AAAA,MACNL,MAAM;AAAA,MACNO,OAAO;AAAA,MACPI,aAAa;AAAA,MACbC,YAAaC,CAAAA,MAAMC,iBAAAA,aAAaD,CAAC;AAAA,MACjCE,SAAS;AAAA,QACPC,QAAQ;AAAA,MAAA;AAAA,IACV,CACD,GACD,GAAGf,MAAM;AAAA,IAEXgB,SAAS;AAAA,MACPC,QAAQ;AAAA,QACNC,OAAO;AAAA,MAAA;AAAA,MAETC,QAAQ;AAAA,QAAED;AAAAA,MAAAA,GAAS;AACjB,eAAO;AAAA,UACLE,UAAUF,QAAQG,YAAAA,8BAA8BH,OAAO,EAAE,IAAII;AAAAA,QAAAA;AAAAA,MAEjE;AAAA,IAAA;AAAA,IAEF,GAAGrB;AAAAA,EAAAA,CACJ;AAED,SAAOsB,MAAAA,YAAgBrB,KAAK;AAC9B;;"}
@@ -1,4 +1,4 @@
1
- import * as sanity69 from "sanity";
1
+ import * as sanity60 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  type Options = Omit<Partial<ObjectDefinition>, "type">;
4
4
  /** @public */
@@ -9,9 +9,9 @@ declare function createBlock({
9
9
  }?: Options): {
10
10
  type: "object";
11
11
  name?: string | undefined;
12
- } & Omit<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
- preview?: sanity69.PreviewConfig<{
12
+ } & Omit<sanity60.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
+ preview?: sanity60.PreviewConfig<{
14
14
  [x: string]: string;
15
15
  }, Record<string, string>> | undefined;
16
- } & sanity69.WidenValidation & sanity69.WidenInitialValue;
16
+ } & sanity60.WidenValidation & sanity60.WidenInitialValue;
17
17
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity68 from "sanity";
1
+ import * as sanity61 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  type Options = Omit<Partial<ObjectDefinition>, "type">;
4
4
  /** @public */
@@ -9,9 +9,9 @@ declare function createBlock({
9
9
  }?: Options): {
10
10
  type: "object";
11
11
  name?: string | undefined;
12
- } & Omit<sanity68.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
- preview?: sanity68.PreviewConfig<{
12
+ } & Omit<sanity61.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
+ preview?: sanity61.PreviewConfig<{
14
14
  [x: string]: string;
15
15
  }, Record<string, string>> | undefined;
16
- } & sanity68.WidenValidation & sanity68.WidenInitialValue;
16
+ } & sanity61.WidenValidation & sanity61.WidenInitialValue;
17
17
  export { createBlock };
@@ -33,7 +33,7 @@ function createBlock({
33
33
  quote
34
34
  }) {
35
35
  return {
36
- subtitle: quote ? createExcerptFromPortableText(quote, 10) : void 0
36
+ subtitle: quote ? createExcerptFromPortableText(quote, 35) : void 0
37
37
  };
38
38
  }
39
39
  },
@@ -1 +1 @@
1
- {"version":3,"file":"quote-block.js","sources":["../../src/blocks/quote-block.tsx"],"sourcesContent":["import { requireQuote } from \"@madebywild/sanity-quote-field\";\nimport { createExcerptFromPortableText } from \"@madebywild/sanity-utils\";\nimport { defineField, type ObjectDefinition } from \"sanity\";\nimport { createBlock as createBaseBlock } from \"../internal-utils\";\nimport { typeName } from \"../types\";\n\ntype Options = Omit<Partial<ObjectDefinition>, \"type\">;\n\nconst kind = \"quote\";\n\n/** @public */\nfunction createBlock({ name, fields = [], ...props }: Options = {}) {\n const field = defineField({\n type: \"object\",\n name: name ?? `${typeName}.block.${kind}`,\n title: \"Quote\",\n icon: () => <>❝❞</>,\n fields: [\n defineField({\n type: \"wild.quote\",\n name: \"quote\",\n title: \"Quote\",\n description: \"Stylized quote content.\",\n validation: (R) => requireQuote(R),\n options: {\n inline: true,\n },\n }),\n ...fields,\n ],\n preview: {\n select: {\n quote: \"quote.quote\",\n },\n prepare({ quote }) {\n return {\n subtitle: quote ? createExcerptFromPortableText(quote, 10) : undefined,\n };\n },\n },\n ...props,\n });\n\n return createBaseBlock(field);\n}\n\nexport { createBlock };\n"],"names":["kind","createBlock","name","fields","props","field","defineField","type","typeName","title","icon","description","validation","R","requireQuote","options","inline","preview","select","quote","prepare","subtitle","createExcerptFromPortableText","undefined","createBaseBlock"],"mappings":";;;;;;AAQA,MAAMA,OAAO;AAGb,SAASC,YAAY;AAAA,EAAEC;AAAAA,EAAMC,SAAS,CAAA;AAAA,EAAI,GAAGC;AAAe,IAAI,IAAI;AAClE,QAAMC,QAAQC,YAAY;AAAA,IACxBC,MAAM;AAAA,IACNL,MAAMA,QAAQ,GAAGM,QAAQ,UAAUR,IAAI;AAAA,IACvCS,OAAO;AAAA,IACPC,MAAMA,MAAM,oBAAA,UAAA,EAAE,UAAA,eAAA,CAAE;AAAA,IAChBP,QAAQ,CACNG,YAAY;AAAA,MACVC,MAAM;AAAA,MACNL,MAAM;AAAA,MACNO,OAAO;AAAA,MACPE,aAAa;AAAA,MACbC,YAAaC,CAAAA,MAAMC,aAAaD,CAAC;AAAA,MACjCE,SAAS;AAAA,QACPC,QAAQ;AAAA,MAAA;AAAA,IACV,CACD,GACD,GAAGb,MAAM;AAAA,IAEXc,SAAS;AAAA,MACPC,QAAQ;AAAA,QACNC,OAAO;AAAA,MAAA;AAAA,MAETC,QAAQ;AAAA,QAAED;AAAAA,MAAAA,GAAS;AACjB,eAAO;AAAA,UACLE,UAAUF,QAAQG,8BAA8BH,OAAO,EAAE,IAAII;AAAAA,QAAAA;AAAAA,MAEjE;AAAA,IAAA;AAAA,IAEF,GAAGnB;AAAAA,EAAAA,CACJ;AAED,SAAOoB,cAAgBnB,KAAK;AAC9B;"}
1
+ {"version":3,"file":"quote-block.js","sources":["../../src/blocks/quote-block.tsx"],"sourcesContent":["import { requireQuote } from \"@madebywild/sanity-quote-field\";\nimport { createExcerptFromPortableText } from \"@madebywild/sanity-utils\";\nimport { defineField, type ObjectDefinition } from \"sanity\";\nimport { createBlock as createBaseBlock } from \"../internal-utils\";\nimport { typeName } from \"../types\";\n\ntype Options = Omit<Partial<ObjectDefinition>, \"type\">;\n\nconst kind = \"quote\";\n\n/** @public */\nfunction createBlock({ name, fields = [], ...props }: Options = {}) {\n const field = defineField({\n type: \"object\",\n name: name ?? `${typeName}.block.${kind}`,\n title: \"Quote\",\n icon: () => <>❝❞</>,\n fields: [\n defineField({\n type: \"wild.quote\",\n name: \"quote\",\n title: \"Quote\",\n description: \"Stylized quote content.\",\n validation: (R) => requireQuote(R),\n options: {\n inline: true,\n },\n }),\n ...fields,\n ],\n preview: {\n select: {\n quote: \"quote.quote\",\n },\n prepare({ quote }) {\n return {\n subtitle: quote ? createExcerptFromPortableText(quote, 35) : undefined,\n };\n },\n },\n ...props,\n });\n\n return createBaseBlock(field);\n}\n\nexport { createBlock };\n"],"names":["kind","createBlock","name","fields","props","field","defineField","type","typeName","title","icon","description","validation","R","requireQuote","options","inline","preview","select","quote","prepare","subtitle","createExcerptFromPortableText","undefined","createBaseBlock"],"mappings":";;;;;;AAQA,MAAMA,OAAO;AAGb,SAASC,YAAY;AAAA,EAAEC;AAAAA,EAAMC,SAAS,CAAA;AAAA,EAAI,GAAGC;AAAe,IAAI,IAAI;AAClE,QAAMC,QAAQC,YAAY;AAAA,IACxBC,MAAM;AAAA,IACNL,MAAMA,QAAQ,GAAGM,QAAQ,UAAUR,IAAI;AAAA,IACvCS,OAAO;AAAA,IACPC,MAAMA,MAAM,oBAAA,UAAA,EAAE,UAAA,eAAA,CAAE;AAAA,IAChBP,QAAQ,CACNG,YAAY;AAAA,MACVC,MAAM;AAAA,MACNL,MAAM;AAAA,MACNO,OAAO;AAAA,MACPE,aAAa;AAAA,MACbC,YAAaC,CAAAA,MAAMC,aAAaD,CAAC;AAAA,MACjCE,SAAS;AAAA,QACPC,QAAQ;AAAA,MAAA;AAAA,IACV,CACD,GACD,GAAGb,MAAM;AAAA,IAEXc,SAAS;AAAA,MACPC,QAAQ;AAAA,QACNC,OAAO;AAAA,MAAA;AAAA,MAETC,QAAQ;AAAA,QAAED;AAAAA,MAAAA,GAAS;AACjB,eAAO;AAAA,UACLE,UAAUF,QAAQG,8BAA8BH,OAAO,EAAE,IAAII;AAAAA,QAAAA;AAAAA,MAEjE;AAAA,IAAA;AAAA,IAEF,GAAGnB;AAAAA,EAAAA,CACJ;AAED,SAAOoB,cAAgBnB,KAAK;AAC9B;"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as sanity60 from "sanity";
1
+ import * as sanity76 from "sanity";
2
2
  import { ArrayDefinition, ArrayOfType, ArrayOptions, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition } from "sanity";
3
3
  /** @public */
4
4
  declare const typeName: "wild.richtext";
@@ -86,5 +86,5 @@ declare module "sanity" {
86
86
  }
87
87
  }
88
88
  /** @public */
89
- declare const wildSanityRichtextFieldPlugin: sanity60.Plugin<PluginConfig>;
89
+ declare const wildSanityRichtextFieldPlugin: sanity76.Plugin<PluginConfig>;
90
90
  export { type FieldOptions, type PluginConfig, typeName, wildSanityRichtextFieldPlugin };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as sanity76 from "sanity";
1
+ import * as sanity60 from "sanity";
2
2
  import { ArrayDefinition, ArrayOfType, ArrayOptions, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition } from "sanity";
3
3
  /** @public */
4
4
  declare const typeName: "wild.richtext";
@@ -86,5 +86,5 @@ declare module "sanity" {
86
86
  }
87
87
  }
88
88
  /** @public */
89
- declare const wildSanityRichtextFieldPlugin: sanity76.Plugin<PluginConfig>;
89
+ declare const wildSanityRichtextFieldPlugin: sanity60.Plugin<PluginConfig>;
90
90
  export { type FieldOptions, type PluginConfig, typeName, wildSanityRichtextFieldPlugin };
package/dist/parts.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import * as sanity77 from "sanity";
2
- import * as react28 from "react";
1
+ import * as sanity81 from "sanity";
2
+ import * as react22 from "react";
3
3
  type ColorAnnotationOptions = {
4
4
  renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
5
5
  };
@@ -10,106 +10,106 @@ declare function createAnnotations(options?: {
10
10
  }): readonly [{
11
11
  type: "wild.link";
12
12
  name: "wild.richtext.annotation.link";
13
- } & sanity77.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.richtext" | "wild.quote" | "wild.media" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
14
- preview?: sanity77.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
15
- } & sanity77.FieldDefinitionBase & sanity77.WidenValidation & sanity77.WidenInitialValue, {
13
+ } & sanity81.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.richtext" | "wild.media" | "wild.quote" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
14
+ preview?: sanity81.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
15
+ } & sanity81.FieldDefinitionBase & sanity81.WidenValidation & sanity81.WidenInitialValue, {
16
16
  type: "object";
17
17
  name: "wild.richtext.annotation.textColor";
18
- } & Omit<sanity77.ObjectDefinition, "preview"> & {
19
- preview?: sanity77.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
20
- } & sanity77.FieldDefinitionBase & sanity77.WidenValidation & sanity77.WidenInitialValue, {
18
+ } & Omit<sanity81.ObjectDefinition, "preview"> & {
19
+ preview?: sanity81.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
20
+ } & sanity81.FieldDefinitionBase & sanity81.WidenValidation & sanity81.WidenInitialValue, {
21
21
  type: "object";
22
22
  name: "wild.richtext.annotation.highlightColor";
23
- } & Omit<sanity77.ObjectDefinition, "preview"> & {
24
- preview?: sanity77.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
25
- } & sanity77.FieldDefinitionBase & sanity77.WidenValidation & sanity77.WidenInitialValue];
23
+ } & Omit<sanity81.ObjectDefinition, "preview"> & {
24
+ preview?: sanity81.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
25
+ } & sanity81.FieldDefinitionBase & sanity81.WidenValidation & sanity81.WidenInitialValue];
26
26
  /** @public */
27
27
  declare function createDecorators(): readonly [{
28
28
  readonly title: "Strong";
29
29
  readonly value: "wild.richtext.decorator.strong";
30
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
30
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
31
31
  readonly component: ({
32
32
  children
33
- }: BlockDecoratorProps) => react28.JSX.Element;
33
+ }: BlockDecoratorProps) => react22.JSX.Element;
34
34
  }, {
35
35
  readonly title: "Emphasis";
36
36
  readonly value: "wild.richtext.decorator.em";
37
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
37
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
38
38
  readonly component: ({
39
39
  children
40
- }: BlockDecoratorProps) => react28.JSX.Element;
40
+ }: BlockDecoratorProps) => react22.JSX.Element;
41
41
  }, {
42
42
  readonly title: "Code";
43
43
  readonly value: "wild.richtext.decorator.code";
44
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
44
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
45
45
  readonly component: ({
46
46
  children
47
- }: BlockDecoratorProps) => react28.JSX.Element;
47
+ }: BlockDecoratorProps) => react22.JSX.Element;
48
48
  }, {
49
49
  readonly title: "Sup";
50
50
  readonly value: "wild.richtext.decorator.sup";
51
- readonly icon: () => react28.JSX.Element;
51
+ readonly icon: () => react22.JSX.Element;
52
52
  readonly component: ({
53
53
  children
54
- }: BlockDecoratorProps) => react28.JSX.Element;
54
+ }: BlockDecoratorProps) => react22.JSX.Element;
55
55
  }];
56
56
  /** @public */
57
57
  declare function createLists(): readonly [{
58
58
  readonly title: "Bullet";
59
59
  readonly value: "wild.richtext.list.bullet";
60
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
60
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
61
61
  }, {
62
62
  readonly title: "Number";
63
63
  readonly value: "wild.richtext.list.number";
64
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
64
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
65
65
  }];
66
66
  type IconSpanOptions = {
67
- renderValue?: (value?: string) => react28.ReactNode;
67
+ renderValue?: (value?: string) => react22.ReactNode;
68
68
  };
69
69
  declare function createIconSpan(options?: IconSpanOptions): {
70
70
  type: "object";
71
71
  name?: "wild.richtext.span.icon" | undefined;
72
- } & Omit<sanity77.ArrayOfEntry<sanity77.ObjectDefinition>, "preview"> & {
73
- preview?: sanity77.PreviewConfig<{
72
+ } & Omit<sanity81.ArrayOfEntry<sanity81.ObjectDefinition>, "preview"> & {
73
+ preview?: sanity81.PreviewConfig<{
74
74
  icon: string;
75
75
  }, Record<"icon", any>> | undefined;
76
- } & sanity77.WidenValidation & sanity77.WidenInitialValue;
76
+ } & sanity81.WidenValidation & sanity81.WidenInitialValue;
77
77
  /** @public */
78
78
  declare function createSpans(options?: {
79
79
  icon?: IconSpanOptions;
80
80
  }): readonly [{
81
81
  type: "object";
82
82
  name?: "wild.richtext.span.icon" | undefined;
83
- } & Omit<sanity77.ArrayOfEntry<sanity77.ObjectDefinition>, "preview"> & {
84
- preview?: sanity77.PreviewConfig<{
83
+ } & Omit<sanity81.ArrayOfEntry<sanity81.ObjectDefinition>, "preview"> & {
84
+ preview?: sanity81.PreviewConfig<{
85
85
  icon: string;
86
86
  }, Record<"icon", any>> | undefined;
87
- } & sanity77.WidenValidation & sanity77.WidenInitialValue, {
87
+ } & sanity81.WidenValidation & sanity81.WidenInitialValue, {
88
88
  type: "object";
89
89
  name?: "wild.richtext.span.media" | undefined;
90
- } & Omit<sanity77.ArrayOfEntry<sanity77.ObjectDefinition>, "preview"> & {
91
- preview?: sanity77.PreviewConfig<{
90
+ } & Omit<sanity81.ArrayOfEntry<sanity81.ObjectDefinition>, "preview"> & {
91
+ preview?: sanity81.PreviewConfig<{
92
92
  kind: string;
93
93
  }, Record<"kind", any>> | undefined;
94
- } & sanity77.WidenValidation & sanity77.WidenInitialValue];
94
+ } & sanity81.WidenValidation & sanity81.WidenInitialValue];
95
95
  /** @public */
96
96
  declare function createStyles(): readonly [{
97
97
  readonly title: "Heading 2";
98
98
  readonly value: "wild.richtext.style.h2";
99
99
  readonly component: ({
100
100
  children
101
- }: BlockStyleProps) => react28.JSX.Element;
101
+ }: BlockStyleProps) => react22.JSX.Element;
102
102
  }, {
103
103
  readonly title: "Heading 3";
104
104
  readonly value: "wild.richtext.style.h3";
105
105
  readonly component: ({
106
106
  children
107
- }: BlockStyleProps) => react28.JSX.Element;
107
+ }: BlockStyleProps) => react22.JSX.Element;
108
108
  }, {
109
109
  readonly title: "Heading 4";
110
110
  readonly value: "wild.richtext.style.h4";
111
111
  readonly component: ({
112
112
  children
113
- }: BlockStyleProps) => react28.JSX.Element;
113
+ }: BlockStyleProps) => react22.JSX.Element;
114
114
  }];
115
115
  export { createAnnotations, createDecorators, createIconSpan, createLists, createSpans, createStyles };
package/dist/parts.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as sanity81 from "sanity";
2
- import * as react28 from "react";
2
+ import * as react22 from "react";
3
3
  type ColorAnnotationOptions = {
4
4
  renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
5
5
  };
@@ -10,7 +10,7 @@ declare function createAnnotations(options?: {
10
10
  }): readonly [{
11
11
  type: "wild.link";
12
12
  name: "wild.richtext.annotation.link";
13
- } & sanity81.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.media" | "wild.richtext" | "wild.quote" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
13
+ } & sanity81.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.richtext" | "wild.quote" | "wild.media" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
14
14
  preview?: sanity81.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
15
15
  } & sanity81.FieldDefinitionBase & sanity81.WidenValidation & sanity81.WidenInitialValue, {
16
16
  type: "object";
@@ -27,44 +27,44 @@ declare function createAnnotations(options?: {
27
27
  declare function createDecorators(): readonly [{
28
28
  readonly title: "Strong";
29
29
  readonly value: "wild.richtext.decorator.strong";
30
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
30
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
31
31
  readonly component: ({
32
32
  children
33
- }: BlockDecoratorProps) => react28.JSX.Element;
33
+ }: BlockDecoratorProps) => react22.JSX.Element;
34
34
  }, {
35
35
  readonly title: "Emphasis";
36
36
  readonly value: "wild.richtext.decorator.em";
37
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
37
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
38
38
  readonly component: ({
39
39
  children
40
- }: BlockDecoratorProps) => react28.JSX.Element;
40
+ }: BlockDecoratorProps) => react22.JSX.Element;
41
41
  }, {
42
42
  readonly title: "Code";
43
43
  readonly value: "wild.richtext.decorator.code";
44
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
44
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
45
45
  readonly component: ({
46
46
  children
47
- }: BlockDecoratorProps) => react28.JSX.Element;
47
+ }: BlockDecoratorProps) => react22.JSX.Element;
48
48
  }, {
49
49
  readonly title: "Sup";
50
50
  readonly value: "wild.richtext.decorator.sup";
51
- readonly icon: () => react28.JSX.Element;
51
+ readonly icon: () => react22.JSX.Element;
52
52
  readonly component: ({
53
53
  children
54
- }: BlockDecoratorProps) => react28.JSX.Element;
54
+ }: BlockDecoratorProps) => react22.JSX.Element;
55
55
  }];
56
56
  /** @public */
57
57
  declare function createLists(): readonly [{
58
58
  readonly title: "Bullet";
59
59
  readonly value: "wild.richtext.list.bullet";
60
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
60
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
61
61
  }, {
62
62
  readonly title: "Number";
63
63
  readonly value: "wild.richtext.list.number";
64
- readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
64
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
65
65
  }];
66
66
  type IconSpanOptions = {
67
- renderValue?: (value?: string) => react28.ReactNode;
67
+ renderValue?: (value?: string) => react22.ReactNode;
68
68
  };
69
69
  declare function createIconSpan(options?: IconSpanOptions): {
70
70
  type: "object";
@@ -98,18 +98,18 @@ declare function createStyles(): readonly [{
98
98
  readonly value: "wild.richtext.style.h2";
99
99
  readonly component: ({
100
100
  children
101
- }: BlockStyleProps) => react28.JSX.Element;
101
+ }: BlockStyleProps) => react22.JSX.Element;
102
102
  }, {
103
103
  readonly title: "Heading 3";
104
104
  readonly value: "wild.richtext.style.h3";
105
105
  readonly component: ({
106
106
  children
107
- }: BlockStyleProps) => react28.JSX.Element;
107
+ }: BlockStyleProps) => react22.JSX.Element;
108
108
  }, {
109
109
  readonly title: "Heading 4";
110
110
  readonly value: "wild.richtext.style.h4";
111
111
  readonly component: ({
112
112
  children
113
- }: BlockStyleProps) => react28.JSX.Element;
113
+ }: BlockStyleProps) => react22.JSX.Element;
114
114
  }];
115
115
  export { createAnnotations, createDecorators, createIconSpan, createLists, createSpans, createStyles };
package/dist/utils.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as sanity107 from "sanity";
1
+ import * as sanity77 from "sanity";
2
2
  import { ObjectDefinition } from "sanity";
3
3
  /**
4
4
  * Creates a schema definition for a new richtext block.
@@ -7,11 +7,11 @@ import { ObjectDefinition } from "sanity";
7
7
  declare function createBlock(block: ObjectDefinition): {
8
8
  type: "object";
9
9
  name?: string | undefined;
10
- } & Omit<sanity107.ArrayOfEntry<ObjectDefinition>, "preview"> & {
11
- preview?: sanity107.PreviewConfig<{
10
+ } & Omit<sanity77.ArrayOfEntry<ObjectDefinition>, "preview"> & {
11
+ preview?: sanity77.PreviewConfig<{
12
12
  [x: string]: string;
13
13
  }, Record<string, string>> | undefined;
14
- } & sanity107.WidenValidation & sanity107.WidenInitialValue;
14
+ } & sanity77.WidenValidation & sanity77.WidenInitialValue;
15
15
  /**
16
16
  * Reshapes the list kind of an array field.
17
17
  */
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@madebywild/sanity-richtext-field",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
- "license": "UNLICENSED",
6
+ "license": "MIT",
7
7
  "browserslist": "extends @sanity/browserslist-config",
8
8
  "exports": {
9
9
  "./package.json": "./package.json",
@@ -52,9 +52,9 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "ts-deepmerge": "^7.0.3",
55
- "@madebywild/sanity-media-field": "1.0.0",
56
- "@madebywild/sanity-quote-field": "1.0.3",
57
- "@madebywild/sanity-utils": "1.0.0"
55
+ "@madebywild/sanity-media-field": "1.0.1",
56
+ "@madebywild/sanity-utils": "1.0.1",
57
+ "@madebywild/sanity-quote-field": "1.1.1"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@sanity/icons": "^3.7.4",
@@ -34,7 +34,7 @@ function createBlock({ name, fields = [], ...props }: Options = {}) {
34
34
  },
35
35
  prepare({ quote }) {
36
36
  return {
37
- subtitle: quote ? createExcerptFromPortableText(quote, 10) : undefined,
37
+ subtitle: quote ? createExcerptFromPortableText(quote, 35) : undefined,
38
38
  };
39
39
  },
40
40
  },