@madebywild/sanity-richtext-field 1.1.0 → 2.0.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 CHANGED
@@ -58,17 +58,17 @@ wildSanityRichtextFieldPlugin({
58
58
  annotations: [
59
59
  ...createAnnotations({
60
60
  textColor: {
61
- renderAnnotation: (props, color) => <span style={{ color }}>{props.renderDefault(props)}</span>,
61
+ renderValue: (value) => getColor(value)?.cssVar,
62
62
  },
63
63
  highlightColor: {
64
- renderAnnotation: (props, color) => <mark style={{ backgroundColor: color }}>{props.renderDefault(props)}</mark>,
64
+ renderValue: (value) => getColor(value)?.cssVar,
65
65
  },
66
66
  }),
67
67
  ],
68
68
  spans: [
69
69
  ...createSpans({
70
70
  icon: {
71
- renderPreview: (value) => <span>{value}</span>,
71
+ renderValuePreview: (value) => <Icon name={value as IconName} />,
72
72
  },
73
73
  }),
74
74
  ],
@@ -1,4 +1,4 @@
1
- import * as sanity68 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<sanity68.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity68.PreviewConfig<{
19
+ } & Omit<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity69.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity68.WidenValidation & sanity68.WidenInitialValue;
23
+ } & sanity69.WidenValidation & sanity69.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity69 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<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity69.PreviewConfig<{
19
+ } & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity73.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity69.WidenValidation & sanity69.WidenInitialValue;
23
+ } & sanity73.WidenValidation & sanity73.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity65 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<sanity65.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity65.PreviewConfig<{
19
+ } & Omit<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity69.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity65.WidenValidation & sanity65.WidenInitialValue;
23
+ } & sanity69.WidenValidation & sanity69.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity64 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<sanity64.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
- preview?: sanity64.PreviewConfig<{
19
+ } & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity73.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity64.WidenValidation & sanity64.WidenInitialValue;
23
+ } & sanity73.WidenValidation & sanity73.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity73 from "sanity";
1
+ import * as sanity61 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<sanity61.ArrayOfEntry<ObjectDefinition>, "preview"> & {
20
+ preview?: sanity61.PreviewConfig<{
21
21
  [x: string]: string;
22
22
  }, Record<string, string>> | undefined;
23
- } & sanity73.WidenValidation & sanity73.WidenInitialValue;
23
+ } & sanity61.WidenValidation & sanity61.WidenInitialValue;
24
24
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity73 from "sanity";
1
+ import * as sanity64 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<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
- preview?: sanity73.PreviewConfig<{
12
+ } & Omit<sanity64.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
+ preview?: sanity64.PreviewConfig<{
14
14
  [x: string]: string;
15
15
  }, Record<string, string>> | undefined;
16
- } & sanity73.WidenValidation & sanity73.WidenInitialValue;
16
+ } & sanity64.WidenValidation & sanity64.WidenInitialValue;
17
17
  export { createBlock };
@@ -1,4 +1,4 @@
1
- import * as sanity61 from "sanity";
1
+ import * as sanity65 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<sanity61.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
- preview?: sanity61.PreviewConfig<{
12
+ } & Omit<sanity65.ArrayOfEntry<ObjectDefinition>, "preview"> & {
13
+ preview?: sanity65.PreviewConfig<{
14
14
  [x: string]: string;
15
15
  }, Record<string, string>> | undefined;
16
- } & sanity61.WidenValidation & sanity61.WidenInitialValue;
16
+ } & sanity65.WidenValidation & sanity65.WidenInitialValue;
17
17
  export { createBlock };
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as sanity72 from "sanity";
1
+ import * as sanity68 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: sanity72.Plugin<PluginConfig>;
89
+ declare const wildSanityRichtextFieldPlugin: sanity68.Plugin<PluginConfig>;
90
90
  export { type FieldOptions, type PluginConfig, typeName, wildSanityRichtextFieldPlugin };
package/dist/parts.cjs CHANGED
@@ -22,17 +22,15 @@ const ColorText = styledComponents.styled.span`
22
22
  background-color: inherit;
23
23
  border-bottom: unset;
24
24
  color: ${({
25
- color = "inherit"
26
- }) => color};
25
+ $color = "inherit"
26
+ }) => $color};
27
27
  }
28
28
  `;
29
29
  function defaultResolveColor(value) {
30
- if (typeof value == "string") return value;
31
- if (value && typeof value == "object" && "value" in value && typeof value.value == "string")
32
- return value.value;
30
+ return value;
33
31
  }
34
32
  function createTextColorAnnotation(options) {
35
- const resolveColor = options?.resolveColor ?? defaultResolveColor, renderAnnotation = options?.renderAnnotation;
33
+ const renderValue = options?.renderValue ?? defaultResolveColor;
36
34
  return sanity.defineField({
37
35
  type: "object",
38
36
  name: `${types.typeName}.annotation.textColor`,
@@ -44,8 +42,8 @@ function createTextColorAnnotation(options) {
44
42
  })],
45
43
  components: {
46
44
  annotation: (props) => {
47
- const color = resolveColor(props.value?.color);
48
- return renderAnnotation ? renderAnnotation(props, color) : /* @__PURE__ */ jsxRuntime.jsx(ColorText, { color, children: props.renderDefault(props) });
45
+ const value = renderValue(props.value?.color);
46
+ return /* @__PURE__ */ jsxRuntime.jsx(ColorText, { $color: value, children: props.renderDefault(props) });
49
47
  }
50
48
  }
51
49
  });
@@ -53,14 +51,14 @@ function createTextColorAnnotation(options) {
53
51
  const ColorBg = styledComponents.styled.span`
54
52
  & > span {
55
53
  background-color: ${({
56
- color = "inherit"
57
- }) => color};
54
+ $color = "inherit"
55
+ }) => $color};
58
56
  border-bottom: unset;
59
57
  color: inherit;
60
58
  }
61
59
  `;
62
60
  function createHighlightColorAnnotation(options) {
63
- const resolveColor = options?.resolveColor ?? defaultResolveColor, renderAnnotation = options?.renderAnnotation;
61
+ const renderValue = options?.renderValue ?? defaultResolveColor;
64
62
  return sanity.defineField({
65
63
  type: "object",
66
64
  name: `${types.typeName}.annotation.highlightColor`,
@@ -72,8 +70,8 @@ function createHighlightColorAnnotation(options) {
72
70
  })],
73
71
  components: {
74
72
  annotation: (props) => {
75
- const color = resolveColor(props.value?.color);
76
- return renderAnnotation ? renderAnnotation(props, color) : /* @__PURE__ */ jsxRuntime.jsx(ColorBg, { color, children: props.renderDefault(props) });
73
+ const value = renderValue(props.value?.color);
74
+ return /* @__PURE__ */ jsxRuntime.jsx(ColorBg, { $color: value, children: props.renderDefault(props) });
77
75
  }
78
76
  }
79
77
  });
@@ -138,10 +136,10 @@ function createLists() {
138
136
  return [bullet, number];
139
137
  }
140
138
  function defaultRenderIconPreview(value) {
141
- return /* @__PURE__ */ jsxRuntime.jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: value ?? "Icon", children: "\u{1F9FF}" });
139
+ return React__namespace.isValidElement(value) ? value : /* @__PURE__ */ jsxRuntime.jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: typeof value == "string" ? value : "Icon", children: "\u{1F9FF}" });
142
140
  }
143
141
  function createIconSpan(options) {
144
- const renderPreview = options?.renderPreview ?? defaultRenderIconPreview;
142
+ const renderValuePreview = options?.renderValuePreview;
145
143
  return sanity.defineArrayMember({
146
144
  name: `${types.typeName}.span.icon`,
147
145
  type: "object",
@@ -165,7 +163,7 @@ function createIconSpan(options) {
165
163
  icon
166
164
  }) {
167
165
  return {
168
- media: renderPreview(icon)
166
+ media: renderValuePreview?.(icon) ?? defaultRenderIconPreview(icon)
169
167
  };
170
168
  }
171
169
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parts.cjs","sources":["../src/parts/annotations/color.tsx","../src/parts/annotations/link.tsx","../src/parts/annotations/index.tsx","../src/parts/decorators/index.tsx","../src/parts/lists/index.tsx","../src/parts/spans/icon.tsx","../src/parts/spans/media.tsx","../src/parts/spans/index.tsx","../src/parts/styles/index.tsx"],"sourcesContent":["import { ColorWheelIcon, HighlightIcon } from \"@sanity/icons\";\nimport { type BlockAnnotationProps, defineField } from \"sanity\";\nimport { styled } from \"styled-components\";\nimport { typeName } from \"../../types\";\n\ntype ColorAnnotationOptions = {\n resolveColor?: (value: unknown) => string | undefined;\n renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;\n};\n\nconst ColorText = styled.span<{ color?: string }>`\n & > span {\n background-color: inherit;\n border-bottom: unset;\n color: ${({ color = \"inherit\" }) => color};\n }\n`;\n\nfunction defaultResolveColor(value: unknown) {\n if (typeof value === \"string\") return value;\n if (value && typeof value === \"object\" && \"value\" in value && typeof value.value === \"string\") {\n return value.value;\n }\n return undefined;\n}\n\nfunction createTextColorAnnotation(options?: ColorAnnotationOptions) {\n const resolveColor = options?.resolveColor ?? defaultResolveColor;\n const renderAnnotation = options?.renderAnnotation;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.textColor`,\n title: \"Text Color\",\n icon: ColorWheelIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const color = resolveColor(props.value?.color);\n if (renderAnnotation) return renderAnnotation(props, color);\n return <ColorText color={color}>{props.renderDefault(props)}</ColorText>;\n },\n },\n });\n}\n\nconst ColorBg = styled.span<{ color?: string }>`\n & > span {\n background-color: ${({ color = \"inherit\" }) => color};\n border-bottom: unset;\n color: inherit;\n }\n`;\n\nfunction createHighlightColorAnnotation(options?: ColorAnnotationOptions) {\n const resolveColor = options?.resolveColor ?? defaultResolveColor;\n const renderAnnotation = options?.renderAnnotation;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.highlightColor`,\n title: \"Highlight Color\",\n icon: HighlightIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const color = resolveColor(props.value?.color);\n if (renderAnnotation) return renderAnnotation(props, color);\n return <ColorBg color={color}>{props.renderDefault(props)}</ColorBg>;\n },\n },\n });\n}\n\nexport { createTextColorAnnotation, createHighlightColorAnnotation, type ColorAnnotationOptions };\n","import { LinkIcon } from \"@sanity/icons\";\nimport { defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const link = defineField({\n type: \"wild.link\",\n name: `${typeName}.annotation.link`,\n title: \"Link\",\n icon: LinkIcon,\n options: {\n collapsed: false,\n collapsible: false,\n },\n});\n","import { type ColorAnnotationOptions, createHighlightColorAnnotation, createTextColorAnnotation } from \"./color\";\nimport { link } from \"./link\";\n\n/** @public */\nfunction createAnnotations(options?: { textColor?: ColorAnnotationOptions; highlightColor?: ColorAnnotationOptions }) {\n return [link, createTextColorAnnotation(options?.textColor), createHighlightColorAnnotation(options?.highlightColor)] as const;\n}\n\nexport { createAnnotations };\n","import { BoldIcon, CodeIcon, ItalicIcon } from \"@sanity/icons\";\nimport type { BlockDecoratorDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst strong = {\n title: \"Strong\",\n value: `${typeName}.decorator.strong`,\n icon: BoldIcon,\n component: ({ children }) => <strong>{children}</strong>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst em = {\n title: \"Emphasis\",\n value: `${typeName}.decorator.em`,\n icon: ItalicIcon,\n component: ({ children }) => <em>{children}</em>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst code = {\n title: \"Code\",\n value: `${typeName}.decorator.code`,\n icon: CodeIcon,\n component: ({ children }) => <code>{children}</code>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst sup = {\n title: \"Sup\",\n value: `${typeName}.decorator.sup`,\n icon: () => <sup>[1]</sup>,\n component: ({ children }) => <sup style={{ verticalAlign: \"super\" }}>{children}</sup>,\n} as const satisfies BlockDecoratorDefinition;\n\n/** @public */\nfunction createDecorators() {\n return [strong, em, code, sup] as const;\n}\n\nexport { createDecorators };\n","import { OlistIcon, UlistIcon } from \"@sanity/icons\";\nimport type { BlockListDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst bullet = {\n title: \"Bullet\",\n value: `${typeName}.list.bullet`,\n icon: UlistIcon,\n} as const satisfies BlockListDefinition;\n\nconst number = {\n title: \"Number\",\n value: `${typeName}.list.number`,\n icon: OlistIcon,\n} as const satisfies BlockListDefinition;\n\n/** @public */\nfunction createLists() {\n return [bullet, number] as const;\n}\n\nexport { createLists };\n","import * as React from \"react\";\nimport { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\ntype IconSpanOptions = {\n renderPreview?: (value?: string) => React.ReactNode;\n};\n\nfunction defaultRenderIconPreview(value?: string) {\n return (\n <span role=\"img\" className=\"inline-block size-[1em] shrink-0 text-current\" title={value ?? \"Icon\"}>\n 🧿\n </span>\n );\n}\n\nfunction createIconSpan(options?: IconSpanOptions) {\n const renderPreview = options?.renderPreview ?? defaultRenderIconPreview;\n\n return defineArrayMember({\n name: `${typeName}.span.icon`,\n type: \"object\",\n title: \"Icon\",\n description: \"Insert an icon.\",\n icon: () => <>🧿</>,\n fields: [defineField({ name: \"icon\", type: \"wild.icon\" })],\n components: {\n // This is the inline-preview in the PortableText editor.\n // It gets its props from the prepare function below.\n preview: (props) => {\n return React.isValidElement(props.media) ? props.media : props.fallbackTitle;\n },\n },\n preview: {\n select: {\n icon: \"icon\",\n },\n prepare({ icon }) {\n return {\n media: renderPreview(icon),\n };\n },\n },\n });\n}\n\nexport { createIconSpan, type IconSpanOptions };\n","import { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const media = defineArrayMember({\n name: `${typeName}.span.media`,\n type: \"object\",\n title: \"Inline Media\",\n description: \"Embed inline video or image content.\",\n icon: () => <>🫧</>,\n fields: [\n defineField({\n name: \"media\",\n type: \"wild.media\",\n options: {\n inline: true,\n },\n }),\n ],\n components: {\n // This is the inline-preview in the PortableText editor.\n preview: (props) => {\n const icons = {\n video: <>🎥</>,\n image: <>🖼️</>,\n motion: <>🌀</>,\n };\n\n // @ts-expect-error: It gets its props from the prepare function below.\n return icons[props.kind as keyof typeof icons] || <>🖼️</>;\n },\n },\n preview: {\n select: {\n kind: \"media.kind\",\n },\n },\n});\n","import { createIconSpan, type IconSpanOptions } from \"./icon\";\nimport { media } from \"./media\";\n\n/** @public */\nfunction createSpans(options?: { icon?: IconSpanOptions }) {\n return [createIconSpan(options?.icon), media] as const;\n}\n\nexport { createSpans };\n","import type { BlockStyleDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst h2 = {\n title: \"Heading 2\",\n value: `${typeName}.style.h2`,\n component: ({ children }) => (\n <h2\n style={{\n fontSize: \"2.0625rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(41 / 33)\",\n }}\n >\n {children}\n </h2>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h3 = {\n title: \"Heading 3\",\n value: `${typeName}.style.h3`,\n component: ({ children }) => (\n <h3\n style={{\n fontSize: \"1.6875rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(35 / 27)\",\n }}\n >\n {children}\n </h3>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h4 = {\n title: \"Heading 4\",\n value: `${typeName}.style.h4`,\n component: ({ children }) => (\n <h4\n style={{\n fontSize: \"1.3125rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(29 / 21)\",\n }}\n >\n {children}\n </h4>\n ),\n} as const satisfies BlockStyleDefinition;\n\n/** @public */\nfunction createStyles() {\n return [h2, h3, h4] as const;\n}\n\nexport { createStyles };\n"],"names":["ColorText","styled","span","color","defaultResolveColor","value","createTextColorAnnotation","options","resolveColor","renderAnnotation","defineField","type","name","typeName","title","icon","ColorWheelIcon","fields","components","annotation","props","jsx","renderDefault","ColorBg","createHighlightColorAnnotation","HighlightIcon","link","LinkIcon","collapsed","collapsible","createAnnotations","textColor","highlightColor","strong","BoldIcon","component","children","em","ItalicIcon","code","CodeIcon","sup","verticalAlign","createDecorators","bullet","UlistIcon","number","OlistIcon","createLists","defaultRenderIconPreview","createIconSpan","renderPreview","defineArrayMember","description","Fragment","preview","React","isValidElement","media","fallbackTitle","select","prepare","inline","video","image","motion","kind","createSpans","h2","fontSize","fontWeight","lineHeight","h3","h4","createStyles"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAMA,YAAYC,iBAAAA,OAAOC;AAAAA;AAAAA;AAAAA;AAAAA,aAIZ,CAAC;AAAA,EAAEC,QAAQ;AAAU,MAAMA,KAAK;AAAA;AAAA;AAI7C,SAASC,oBAAoBC,OAAgB;AAC3C,MAAI,OAAOA,SAAU,SAAU,QAAOA;AACtC,MAAIA,SAAS,OAAOA,SAAU,YAAY,WAAWA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Y;AAAA,EAAA,GAGbnC,SAAAA,CACH;AAEJ,GAEMoC,KAAK;AAAA,EACT1D,OAAO;AAAA,EACPT,OAAO,GAAGQ,MAAAA,QAAQ;AAAA,EAClBsB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZf,2BAAAA,IAAC,MAAA,EACC,OAAO;AAAA,IACLgD,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGbnC,SAAAA,CACH;AAEJ,GAEMqC,KAAK;AAAA,EACT3D,OAAO;AAAA,EACPT,OAAO,GAAGQ,MAAAA,QAAQ;AAAA,EAClBsB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZf,2BAAAA,IAAC,MAAA,EACC,OAAO;AAAA,IACLgD,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGbnC,SAAAA,CACH;AAEJ;AAGA,SAASsC,eAAe;AACtB,SAAO,CAACN,IAAII,IAAIC,EAAE;AACpB;;;;;;;"}
1
+ {"version":3,"file":"parts.cjs","sources":["../src/parts/annotations/color.tsx","../src/parts/annotations/link.tsx","../src/parts/annotations/index.tsx","../src/parts/decorators/index.tsx","../src/parts/lists/index.tsx","../src/parts/spans/icon.tsx","../src/parts/spans/media.tsx","../src/parts/spans/index.tsx","../src/parts/styles/index.tsx"],"sourcesContent":["import { ColorWheelIcon, HighlightIcon } from \"@sanity/icons\";\nimport { defineField } from \"sanity\";\nimport { styled } from \"styled-components\";\nimport { typeName } from \"../../types\";\n\ntype ColorAnnotationOptions = {\n renderValue?: (value: string | undefined) => string | undefined;\n};\n\nconst ColorText = styled.span<{ $color?: string }>`\n & > span {\n background-color: inherit;\n border-bottom: unset;\n color: ${({ $color = \"inherit\" }) => $color};\n }\n`;\n\nfunction defaultResolveColor(value: string | undefined) {\n return value;\n}\n\nfunction createTextColorAnnotation(options?: ColorAnnotationOptions) {\n const renderValue = options?.renderValue ?? defaultResolveColor;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.textColor`,\n title: \"Text Color\",\n icon: ColorWheelIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const value = renderValue(props.value?.color);\n return <ColorText $color={value}>{props.renderDefault(props)}</ColorText>;\n },\n },\n });\n}\n\nconst ColorBg = styled.span<{ $color?: string }>`\n & > span {\n background-color: ${({ $color = \"inherit\" }) => $color};\n border-bottom: unset;\n color: inherit;\n }\n`;\n\nfunction createHighlightColorAnnotation(options?: ColorAnnotationOptions) {\n const renderValue = options?.renderValue ?? defaultResolveColor;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.highlightColor`,\n title: \"Highlight Color\",\n icon: HighlightIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const value = renderValue(props.value?.color);\n return <ColorBg $color={value}>{props.renderDefault(props)}</ColorBg>;\n },\n },\n });\n}\n\nexport { createTextColorAnnotation, createHighlightColorAnnotation, type ColorAnnotationOptions };\n","import { LinkIcon } from \"@sanity/icons\";\nimport { defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const link = defineField({\n type: \"wild.link\",\n name: `${typeName}.annotation.link`,\n title: \"Link\",\n icon: LinkIcon,\n options: {\n collapsed: false,\n collapsible: false,\n },\n});\n","import { type ColorAnnotationOptions, createHighlightColorAnnotation, createTextColorAnnotation } from \"./color\";\nimport { link } from \"./link\";\n\n/** @public */\nfunction createAnnotations(options?: { textColor?: ColorAnnotationOptions; highlightColor?: ColorAnnotationOptions }) {\n return [link, createTextColorAnnotation(options?.textColor), createHighlightColorAnnotation(options?.highlightColor)] as const;\n}\n\nexport { createAnnotations };\n","import { BoldIcon, CodeIcon, ItalicIcon } from \"@sanity/icons\";\nimport type { BlockDecoratorDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst strong = {\n title: \"Strong\",\n value: `${typeName}.decorator.strong`,\n icon: BoldIcon,\n component: ({ children }) => <strong>{children}</strong>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst em = {\n title: \"Emphasis\",\n value: `${typeName}.decorator.em`,\n icon: ItalicIcon,\n component: ({ children }) => <em>{children}</em>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst code = {\n title: \"Code\",\n value: `${typeName}.decorator.code`,\n icon: CodeIcon,\n component: ({ children }) => <code>{children}</code>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst sup = {\n title: \"Sup\",\n value: `${typeName}.decorator.sup`,\n icon: () => <sup>[1]</sup>,\n component: ({ children }) => <sup style={{ verticalAlign: \"super\" }}>{children}</sup>,\n} as const satisfies BlockDecoratorDefinition;\n\n/** @public */\nfunction createDecorators() {\n return [strong, em, code, sup] as const;\n}\n\nexport { createDecorators };\n","import { OlistIcon, UlistIcon } from \"@sanity/icons\";\nimport type { BlockListDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst bullet = {\n title: \"Bullet\",\n value: `${typeName}.list.bullet`,\n icon: UlistIcon,\n} as const satisfies BlockListDefinition;\n\nconst number = {\n title: \"Number\",\n value: `${typeName}.list.number`,\n icon: OlistIcon,\n} as const satisfies BlockListDefinition;\n\n/** @public */\nfunction createLists() {\n return [bullet, number] as const;\n}\n\nexport { createLists };\n","import * as React from \"react\";\nimport { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\ntype IconSpanOptions = {\n renderValuePreview?: (value?: string) => React.ReactNode;\n};\n\nfunction defaultRenderIconPreview(value?: React.ReactNode) {\n if (React.isValidElement(value)) return value;\n return (\n <span role=\"img\" className=\"inline-block size-[1em] shrink-0 text-current\" title={typeof value === \"string\" ? value : \"Icon\"}>\n 🧿\n </span>\n );\n}\n\nfunction createIconSpan(options?: IconSpanOptions) {\n const renderValuePreview = options?.renderValuePreview;\n\n return defineArrayMember({\n name: `${typeName}.span.icon`,\n type: \"object\",\n title: \"Icon\",\n description: \"Insert an icon.\",\n icon: () => <>🧿</>,\n fields: [defineField({ name: \"icon\", type: \"wild.icon\" })],\n components: {\n // This is the inline-preview in the PortableText editor.\n // It gets its props from the prepare function below.\n preview: (props) => {\n return React.isValidElement(props.media) ? props.media : props.fallbackTitle;\n },\n },\n preview: {\n select: {\n icon: \"icon\",\n },\n prepare({ icon }) {\n return {\n media: renderValuePreview?.(icon) ?? defaultRenderIconPreview(icon),\n };\n },\n },\n });\n}\n\nexport { createIconSpan, type IconSpanOptions };\n","import { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const media = defineArrayMember({\n name: `${typeName}.span.media`,\n type: \"object\",\n title: \"Inline Media\",\n description: \"Embed inline video or image content.\",\n icon: () => <>🫧</>,\n fields: [\n defineField({\n name: \"media\",\n type: \"wild.media\",\n options: {\n inline: true,\n },\n }),\n ],\n components: {\n // This is the inline-preview in the PortableText editor.\n preview: (props) => {\n const icons = {\n video: <>🎥</>,\n image: <>🖼️</>,\n motion: <>🌀</>,\n };\n\n // @ts-expect-error: It gets its props from the prepare function below.\n return icons[props.kind as keyof typeof icons] || <>🖼️</>;\n },\n },\n preview: {\n select: {\n kind: \"media.kind\",\n },\n },\n});\n","import { createIconSpan, type IconSpanOptions } from \"./icon\";\nimport { media } from \"./media\";\n\n/** @public */\nfunction createSpans(options?: { icon?: IconSpanOptions }) {\n return [createIconSpan(options?.icon), media] as const;\n}\n\nexport { createSpans };\n","import type { BlockStyleDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst h2 = {\n title: \"Heading 2\",\n value: `${typeName}.style.h2`,\n component: ({ children }) => (\n <h2\n style={{\n fontSize: \"2.0625rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(41 / 33)\",\n }}\n >\n {children}\n </h2>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h3 = {\n title: \"Heading 3\",\n value: `${typeName}.style.h3`,\n component: ({ children }) => (\n <h3\n style={{\n fontSize: \"1.6875rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(35 / 27)\",\n }}\n >\n {children}\n </h3>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h4 = {\n title: \"Heading 4\",\n value: `${typeName}.style.h4`,\n component: ({ children }) => (\n <h4\n style={{\n fontSize: \"1.3125rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(29 / 21)\",\n }}\n >\n {children}\n </h4>\n ),\n} as const satisfies BlockStyleDefinition;\n\n/** @public */\nfunction createStyles() {\n return [h2, h3, h4] as const;\n}\n\nexport { createStyles };\n"],"names":["ColorText","styled","span","$color","defaultResolveColor","value","createTextColorAnnotation","options","renderValue","defineField","type","name","typeName","title","icon","ColorWheelIcon","fields","components","annotation","props","color","renderDefault","ColorBg","createHighlightColorAnnotation","HighlightIcon","link","LinkIcon","collapsed","collapsible","createAnnotations","textColor","highlightColor","strong","BoldIcon","component","children","jsx","em","ItalicIcon","code","CodeIcon","sup","verticalAlign","createDecorators","bullet","UlistIcon","number","OlistIcon","createLists","defaultRenderIconPreview","React","isValidElement","createIconSpan","renderValuePreview","defineArrayMember","description","Fragment","preview","media","fallbackTitle","select","prepare","inline","video","image","motion","kind","createSpans","h2","fontSize","fontWeight","lineHeight","h3","h4","createStyles"],"mappings":";;;;;;;;;;;;;;;;;;;AASA,MAAMA,YAAYC,iBAAAA,OAAOC;AAAAA;AAAAA;AAAAA;AAAAA,aAIZ,CAAC;AAAA,EAAEC,SAAS;AAAU,MAAMA,MAAM;AAAA;AAAA;AAI/C,SAASC,oBAAoBC,OAA2B;AACtD,SAAOA;AACT;AAEA,SAASC,0BAA0BC,SAAkC;AACnE,QAAMC,cAAcD,SAASC,eAAeJ;AAE5C,SAAOK,mBAAY;AAAA,IACjBC,MAAM;AAAA,IACNC,MAAM,GAAGC,MAAAA,QAAQ;AAAA,IACjBC,OAAO;AAAA,IACPC,MAAMC,MAAAA;AAAAA,IACNC,QAAQ,CAACP,OAAAA,YAAY;AAAA,MAAEE,MAAM;AAAA,MAASD,MAAM;AAAA,IAAA,CAAc,CAAC;AAAA,IAC3DO,YAA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O;AAAA,IACLiC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGbpC,SAAAA,CACH;AAEJ;AAGA,SAASuC,eAAe;AACtB,SAAO,CAACN,IAAII,IAAIC,EAAE;AACpB;;;;;;;"}
package/dist/parts.d.cts CHANGED
@@ -1,9 +1,7 @@
1
1
  import * as sanity77 from "sanity";
2
- import { BlockAnnotationProps } from "sanity";
3
- import * as react31 from "react";
2
+ import * as react22 from "react";
4
3
  type ColorAnnotationOptions = {
5
- resolveColor?: (value: unknown) => string | undefined;
6
- renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;
4
+ renderValue?: (value: string | undefined) => string | undefined;
7
5
  };
8
6
  /** @public */
9
7
  declare function createAnnotations(options?: {
@@ -12,7 +10,7 @@ declare function createAnnotations(options?: {
12
10
  }): readonly [{
13
11
  type: "wild.link";
14
12
  name: "wild.richtext.annotation.link";
15
- } & sanity77.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
+ } & sanity77.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> & {
16
14
  preview?: sanity77.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
17
15
  } & sanity77.FieldDefinitionBase & sanity77.WidenValidation & sanity77.WidenInitialValue, {
18
16
  type: "object";
@@ -29,44 +27,44 @@ declare function createAnnotations(options?: {
29
27
  declare function createDecorators(): readonly [{
30
28
  readonly title: "Strong";
31
29
  readonly value: "wild.richtext.decorator.strong";
32
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
30
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
33
31
  readonly component: ({
34
32
  children
35
- }: BlockDecoratorProps) => react31.JSX.Element;
33
+ }: BlockDecoratorProps) => react22.JSX.Element;
36
34
  }, {
37
35
  readonly title: "Emphasis";
38
36
  readonly value: "wild.richtext.decorator.em";
39
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
37
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
40
38
  readonly component: ({
41
39
  children
42
- }: BlockDecoratorProps) => react31.JSX.Element;
40
+ }: BlockDecoratorProps) => react22.JSX.Element;
43
41
  }, {
44
42
  readonly title: "Code";
45
43
  readonly value: "wild.richtext.decorator.code";
46
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
44
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
47
45
  readonly component: ({
48
46
  children
49
- }: BlockDecoratorProps) => react31.JSX.Element;
47
+ }: BlockDecoratorProps) => react22.JSX.Element;
50
48
  }, {
51
49
  readonly title: "Sup";
52
50
  readonly value: "wild.richtext.decorator.sup";
53
- readonly icon: () => react31.JSX.Element;
51
+ readonly icon: () => react22.JSX.Element;
54
52
  readonly component: ({
55
53
  children
56
- }: BlockDecoratorProps) => react31.JSX.Element;
54
+ }: BlockDecoratorProps) => react22.JSX.Element;
57
55
  }];
58
56
  /** @public */
59
57
  declare function createLists(): readonly [{
60
58
  readonly title: "Bullet";
61
59
  readonly value: "wild.richtext.list.bullet";
62
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
60
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
63
61
  }, {
64
62
  readonly title: "Number";
65
63
  readonly value: "wild.richtext.list.number";
66
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
64
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
67
65
  }];
68
66
  type IconSpanOptions = {
69
- renderPreview?: (value?: string) => react31.ReactNode;
67
+ renderValuePreview?: (value?: string) => react22.ReactNode;
70
68
  };
71
69
  declare function createIconSpan(options?: IconSpanOptions): {
72
70
  type: "object";
@@ -100,18 +98,18 @@ declare function createStyles(): readonly [{
100
98
  readonly value: "wild.richtext.style.h2";
101
99
  readonly component: ({
102
100
  children
103
- }: BlockStyleProps) => react31.JSX.Element;
101
+ }: BlockStyleProps) => react22.JSX.Element;
104
102
  }, {
105
103
  readonly title: "Heading 3";
106
104
  readonly value: "wild.richtext.style.h3";
107
105
  readonly component: ({
108
106
  children
109
- }: BlockStyleProps) => react31.JSX.Element;
107
+ }: BlockStyleProps) => react22.JSX.Element;
110
108
  }, {
111
109
  readonly title: "Heading 4";
112
110
  readonly value: "wild.richtext.style.h4";
113
111
  readonly component: ({
114
112
  children
115
- }: BlockStyleProps) => react31.JSX.Element;
113
+ }: BlockStyleProps) => react22.JSX.Element;
116
114
  }];
117
115
  export { createAnnotations, createDecorators, createIconSpan, createLists, createSpans, createStyles };
package/dist/parts.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import * as sanity81 from "sanity";
2
- import { BlockAnnotationProps } from "sanity";
3
- import * as react31 from "react";
2
+ import * as react22 from "react";
4
3
  type ColorAnnotationOptions = {
5
- resolveColor?: (value: unknown) => string | undefined;
6
- renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;
4
+ renderValue?: (value: string | undefined) => string | undefined;
7
5
  };
8
6
  /** @public */
9
7
  declare function createAnnotations(options?: {
@@ -29,44 +27,44 @@ declare function createAnnotations(options?: {
29
27
  declare function createDecorators(): readonly [{
30
28
  readonly title: "Strong";
31
29
  readonly value: "wild.richtext.decorator.strong";
32
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
30
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
33
31
  readonly component: ({
34
32
  children
35
- }: BlockDecoratorProps) => react31.JSX.Element;
33
+ }: BlockDecoratorProps) => react22.JSX.Element;
36
34
  }, {
37
35
  readonly title: "Emphasis";
38
36
  readonly value: "wild.richtext.decorator.em";
39
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
37
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
40
38
  readonly component: ({
41
39
  children
42
- }: BlockDecoratorProps) => react31.JSX.Element;
40
+ }: BlockDecoratorProps) => react22.JSX.Element;
43
41
  }, {
44
42
  readonly title: "Code";
45
43
  readonly value: "wild.richtext.decorator.code";
46
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
44
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
47
45
  readonly component: ({
48
46
  children
49
- }: BlockDecoratorProps) => react31.JSX.Element;
47
+ }: BlockDecoratorProps) => react22.JSX.Element;
50
48
  }, {
51
49
  readonly title: "Sup";
52
50
  readonly value: "wild.richtext.decorator.sup";
53
- readonly icon: () => react31.JSX.Element;
51
+ readonly icon: () => react22.JSX.Element;
54
52
  readonly component: ({
55
53
  children
56
- }: BlockDecoratorProps) => react31.JSX.Element;
54
+ }: BlockDecoratorProps) => react22.JSX.Element;
57
55
  }];
58
56
  /** @public */
59
57
  declare function createLists(): readonly [{
60
58
  readonly title: "Bullet";
61
59
  readonly value: "wild.richtext.list.bullet";
62
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
60
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
63
61
  }, {
64
62
  readonly title: "Number";
65
63
  readonly value: "wild.richtext.list.number";
66
- readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
64
+ readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
67
65
  }];
68
66
  type IconSpanOptions = {
69
- renderPreview?: (value?: string) => react31.ReactNode;
67
+ renderValuePreview?: (value?: string) => react22.ReactNode;
70
68
  };
71
69
  declare function createIconSpan(options?: IconSpanOptions): {
72
70
  type: "object";
@@ -100,18 +98,18 @@ declare function createStyles(): readonly [{
100
98
  readonly value: "wild.richtext.style.h2";
101
99
  readonly component: ({
102
100
  children
103
- }: BlockStyleProps) => react31.JSX.Element;
101
+ }: BlockStyleProps) => react22.JSX.Element;
104
102
  }, {
105
103
  readonly title: "Heading 3";
106
104
  readonly value: "wild.richtext.style.h3";
107
105
  readonly component: ({
108
106
  children
109
- }: BlockStyleProps) => react31.JSX.Element;
107
+ }: BlockStyleProps) => react22.JSX.Element;
110
108
  }, {
111
109
  readonly title: "Heading 4";
112
110
  readonly value: "wild.richtext.style.h4";
113
111
  readonly component: ({
114
112
  children
115
- }: BlockStyleProps) => react31.JSX.Element;
113
+ }: BlockStyleProps) => react22.JSX.Element;
116
114
  }];
117
115
  export { createAnnotations, createDecorators, createIconSpan, createLists, createSpans, createStyles };
package/dist/parts.js CHANGED
@@ -9,17 +9,15 @@ const ColorText = styled.span`
9
9
  background-color: inherit;
10
10
  border-bottom: unset;
11
11
  color: ${({
12
- color = "inherit"
13
- }) => color};
12
+ $color = "inherit"
13
+ }) => $color};
14
14
  }
15
15
  `;
16
16
  function defaultResolveColor(value) {
17
- if (typeof value == "string") return value;
18
- if (value && typeof value == "object" && "value" in value && typeof value.value == "string")
19
- return value.value;
17
+ return value;
20
18
  }
21
19
  function createTextColorAnnotation(options) {
22
- const resolveColor = options?.resolveColor ?? defaultResolveColor, renderAnnotation = options?.renderAnnotation;
20
+ const renderValue = options?.renderValue ?? defaultResolveColor;
23
21
  return defineField({
24
22
  type: "object",
25
23
  name: `${typeName}.annotation.textColor`,
@@ -31,8 +29,8 @@ function createTextColorAnnotation(options) {
31
29
  })],
32
30
  components: {
33
31
  annotation: (props) => {
34
- const color = resolveColor(props.value?.color);
35
- return renderAnnotation ? renderAnnotation(props, color) : /* @__PURE__ */ jsx(ColorText, { color, children: props.renderDefault(props) });
32
+ const value = renderValue(props.value?.color);
33
+ return /* @__PURE__ */ jsx(ColorText, { $color: value, children: props.renderDefault(props) });
36
34
  }
37
35
  }
38
36
  });
@@ -40,14 +38,14 @@ function createTextColorAnnotation(options) {
40
38
  const ColorBg = styled.span`
41
39
  & > span {
42
40
  background-color: ${({
43
- color = "inherit"
44
- }) => color};
41
+ $color = "inherit"
42
+ }) => $color};
45
43
  border-bottom: unset;
46
44
  color: inherit;
47
45
  }
48
46
  `;
49
47
  function createHighlightColorAnnotation(options) {
50
- const resolveColor = options?.resolveColor ?? defaultResolveColor, renderAnnotation = options?.renderAnnotation;
48
+ const renderValue = options?.renderValue ?? defaultResolveColor;
51
49
  return defineField({
52
50
  type: "object",
53
51
  name: `${typeName}.annotation.highlightColor`,
@@ -59,8 +57,8 @@ function createHighlightColorAnnotation(options) {
59
57
  })],
60
58
  components: {
61
59
  annotation: (props) => {
62
- const color = resolveColor(props.value?.color);
63
- return renderAnnotation ? renderAnnotation(props, color) : /* @__PURE__ */ jsx(ColorBg, { color, children: props.renderDefault(props) });
60
+ const value = renderValue(props.value?.color);
61
+ return /* @__PURE__ */ jsx(ColorBg, { $color: value, children: props.renderDefault(props) });
64
62
  }
65
63
  }
66
64
  });
@@ -125,10 +123,10 @@ function createLists() {
125
123
  return [bullet, number];
126
124
  }
127
125
  function defaultRenderIconPreview(value) {
128
- return /* @__PURE__ */ jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: value ?? "Icon", children: "\u{1F9FF}" });
126
+ return React.isValidElement(value) ? value : /* @__PURE__ */ jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: typeof value == "string" ? value : "Icon", children: "\u{1F9FF}" });
129
127
  }
130
128
  function createIconSpan(options) {
131
- const renderPreview = options?.renderPreview ?? defaultRenderIconPreview;
129
+ const renderValuePreview = options?.renderValuePreview;
132
130
  return defineArrayMember({
133
131
  name: `${typeName}.span.icon`,
134
132
  type: "object",
@@ -152,7 +150,7 @@ function createIconSpan(options) {
152
150
  icon
153
151
  }) {
154
152
  return {
155
- media: renderPreview(icon)
153
+ media: renderValuePreview?.(icon) ?? defaultRenderIconPreview(icon)
156
154
  };
157
155
  }
158
156
  }
package/dist/parts.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"parts.js","sources":["../src/parts/annotations/color.tsx","../src/parts/annotations/link.tsx","../src/parts/annotations/index.tsx","../src/parts/decorators/index.tsx","../src/parts/lists/index.tsx","../src/parts/spans/icon.tsx","../src/parts/spans/media.tsx","../src/parts/spans/index.tsx","../src/parts/styles/index.tsx"],"sourcesContent":["import { ColorWheelIcon, HighlightIcon } from \"@sanity/icons\";\nimport { type BlockAnnotationProps, defineField } from \"sanity\";\nimport { styled } from \"styled-components\";\nimport { typeName } from \"../../types\";\n\ntype ColorAnnotationOptions = {\n resolveColor?: (value: unknown) => string | undefined;\n renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;\n};\n\nconst ColorText = styled.span<{ color?: string }>`\n & > span {\n background-color: inherit;\n border-bottom: unset;\n color: ${({ color = \"inherit\" }) => color};\n }\n`;\n\nfunction defaultResolveColor(value: unknown) {\n if (typeof value === \"string\") return value;\n if (value && typeof value === \"object\" && \"value\" in value && typeof value.value === \"string\") {\n return value.value;\n }\n return undefined;\n}\n\nfunction createTextColorAnnotation(options?: ColorAnnotationOptions) {\n const resolveColor = options?.resolveColor ?? defaultResolveColor;\n const renderAnnotation = options?.renderAnnotation;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.textColor`,\n title: \"Text Color\",\n icon: ColorWheelIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const color = resolveColor(props.value?.color);\n if (renderAnnotation) return renderAnnotation(props, color);\n return <ColorText color={color}>{props.renderDefault(props)}</ColorText>;\n },\n },\n });\n}\n\nconst ColorBg = styled.span<{ color?: string }>`\n & > span {\n background-color: ${({ color = \"inherit\" }) => color};\n border-bottom: unset;\n color: inherit;\n }\n`;\n\nfunction createHighlightColorAnnotation(options?: ColorAnnotationOptions) {\n const resolveColor = options?.resolveColor ?? defaultResolveColor;\n const renderAnnotation = options?.renderAnnotation;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.highlightColor`,\n title: \"Highlight Color\",\n icon: HighlightIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const color = resolveColor(props.value?.color);\n if (renderAnnotation) return renderAnnotation(props, color);\n return <ColorBg color={color}>{props.renderDefault(props)}</ColorBg>;\n },\n },\n });\n}\n\nexport { createTextColorAnnotation, createHighlightColorAnnotation, type ColorAnnotationOptions };\n","import { LinkIcon } from \"@sanity/icons\";\nimport { defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const link = defineField({\n type: \"wild.link\",\n name: `${typeName}.annotation.link`,\n title: \"Link\",\n icon: LinkIcon,\n options: {\n collapsed: false,\n collapsible: false,\n },\n});\n","import { type ColorAnnotationOptions, createHighlightColorAnnotation, createTextColorAnnotation } from \"./color\";\nimport { link } from \"./link\";\n\n/** @public */\nfunction createAnnotations(options?: { textColor?: ColorAnnotationOptions; highlightColor?: ColorAnnotationOptions }) {\n return [link, createTextColorAnnotation(options?.textColor), createHighlightColorAnnotation(options?.highlightColor)] as const;\n}\n\nexport { createAnnotations };\n","import { BoldIcon, CodeIcon, ItalicIcon } from \"@sanity/icons\";\nimport type { BlockDecoratorDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst strong = {\n title: \"Strong\",\n value: `${typeName}.decorator.strong`,\n icon: BoldIcon,\n component: ({ children }) => <strong>{children}</strong>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst em = {\n title: \"Emphasis\",\n value: `${typeName}.decorator.em`,\n icon: ItalicIcon,\n component: ({ children }) => <em>{children}</em>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst code = {\n title: \"Code\",\n value: `${typeName}.decorator.code`,\n icon: CodeIcon,\n component: ({ children }) => <code>{children}</code>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst sup = {\n title: \"Sup\",\n value: `${typeName}.decorator.sup`,\n icon: () => <sup>[1]</sup>,\n component: ({ children }) => <sup style={{ verticalAlign: \"super\" }}>{children}</sup>,\n} as const satisfies BlockDecoratorDefinition;\n\n/** @public */\nfunction createDecorators() {\n return [strong, em, code, sup] as const;\n}\n\nexport { createDecorators };\n","import { OlistIcon, UlistIcon } from \"@sanity/icons\";\nimport type { BlockListDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst bullet = {\n title: \"Bullet\",\n value: `${typeName}.list.bullet`,\n icon: UlistIcon,\n} as const satisfies BlockListDefinition;\n\nconst number = {\n title: \"Number\",\n value: `${typeName}.list.number`,\n icon: OlistIcon,\n} as const satisfies BlockListDefinition;\n\n/** @public */\nfunction createLists() {\n return [bullet, number] as const;\n}\n\nexport { createLists };\n","import * as React from \"react\";\nimport { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\ntype IconSpanOptions = {\n renderPreview?: (value?: string) => React.ReactNode;\n};\n\nfunction defaultRenderIconPreview(value?: string) {\n return (\n <span role=\"img\" className=\"inline-block size-[1em] shrink-0 text-current\" title={value ?? \"Icon\"}>\n 🧿\n </span>\n );\n}\n\nfunction createIconSpan(options?: IconSpanOptions) {\n const renderPreview = options?.renderPreview ?? defaultRenderIconPreview;\n\n return defineArrayMember({\n name: `${typeName}.span.icon`,\n type: \"object\",\n title: \"Icon\",\n description: \"Insert an icon.\",\n icon: () => <>🧿</>,\n fields: [defineField({ name: \"icon\", type: \"wild.icon\" })],\n components: {\n // This is the inline-preview in the PortableText editor.\n // It gets its props from the prepare function below.\n preview: (props) => {\n return React.isValidElement(props.media) ? props.media : props.fallbackTitle;\n },\n },\n preview: {\n select: {\n icon: \"icon\",\n },\n prepare({ icon }) {\n return {\n media: renderPreview(icon),\n };\n },\n },\n });\n}\n\nexport { createIconSpan, type IconSpanOptions };\n","import { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const media = defineArrayMember({\n name: `${typeName}.span.media`,\n type: \"object\",\n title: \"Inline Media\",\n description: \"Embed inline video or image content.\",\n icon: () => <>🫧</>,\n fields: [\n defineField({\n name: \"media\",\n type: \"wild.media\",\n options: {\n inline: true,\n },\n }),\n ],\n components: {\n // This is the inline-preview in the PortableText editor.\n preview: (props) => {\n const icons = {\n video: <>🎥</>,\n image: <>🖼️</>,\n motion: <>🌀</>,\n };\n\n // @ts-expect-error: It gets its props from the prepare function below.\n return icons[props.kind as keyof typeof icons] || <>🖼️</>;\n },\n },\n preview: {\n select: {\n kind: \"media.kind\",\n },\n },\n});\n","import { createIconSpan, type IconSpanOptions } from \"./icon\";\nimport { media } from \"./media\";\n\n/** @public */\nfunction createSpans(options?: { icon?: IconSpanOptions }) {\n return [createIconSpan(options?.icon), media] as const;\n}\n\nexport { createSpans };\n","import type { BlockStyleDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst h2 = {\n title: \"Heading 2\",\n value: `${typeName}.style.h2`,\n component: ({ children }) => (\n <h2\n style={{\n fontSize: \"2.0625rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(41 / 33)\",\n }}\n >\n {children}\n </h2>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h3 = {\n title: \"Heading 3\",\n value: `${typeName}.style.h3`,\n component: ({ children }) => (\n <h3\n style={{\n fontSize: \"1.6875rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(35 / 27)\",\n }}\n >\n {children}\n </h3>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h4 = {\n title: \"Heading 4\",\n value: `${typeName}.style.h4`,\n component: ({ children }) => (\n <h4\n style={{\n fontSize: \"1.3125rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(29 / 21)\",\n }}\n >\n {children}\n </h4>\n ),\n} as const satisfies BlockStyleDefinition;\n\n/** @public */\nfunction createStyles() {\n return [h2, h3, h4] as const;\n}\n\nexport { createStyles };\n"],"names":["ColorText","styled","span","color","defaultResolveColor","value","createTextColorAnnotation","options","resolveColor","renderAnnotation","defineField","type","name","typeName","title","icon","ColorWheelIcon","fields","components","annotation","props","renderDefault","ColorBg","createHighlightColorAnnotation","HighlightIcon","link","LinkIcon","collapsed","collapsible","createAnnotations","textColor","highlightColor","strong","BoldIcon","component","children","em","ItalicIcon","code","CodeIcon","sup","verticalAlign","createDecorators","bullet","UlistIcon","number","OlistIcon","createLists","defaultRenderIconPreview","createIconSpan","renderPreview","defineArrayMember","description","preview","React","isValidElement","media","fallbackTitle","select","prepare","inline","video","image","motion","kind","createSpans","h2","fontSize","fontWeight","lineHeight","h3","h4","createStyles"],"mappings":";;;;;;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AA,EACPT,OAAO,GAAGQ,QAAQ;AAAA,EAClBqB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZ,oBAAC,MAAA,EACC,OAAO;AAAA,IACLgC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGblC,SAAAA,CACH;AAEJ,GAEMoC,KAAK;AAAA,EACTzD,OAAO;AAAA,EACPT,OAAO,GAAGQ,QAAQ;AAAA,EAClBqB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZ,oBAAC,MAAA,EACC,OAAO;AAAA,IACLgC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGblC,SAAAA,CACH;AAEJ;AAGA,SAASqC,eAAe;AACtB,SAAO,CAACN,IAAII,IAAIC,EAAE;AACpB;"}
1
+ {"version":3,"file":"parts.js","sources":["../src/parts/annotations/color.tsx","../src/parts/annotations/link.tsx","../src/parts/annotations/index.tsx","../src/parts/decorators/index.tsx","../src/parts/lists/index.tsx","../src/parts/spans/icon.tsx","../src/parts/spans/media.tsx","../src/parts/spans/index.tsx","../src/parts/styles/index.tsx"],"sourcesContent":["import { ColorWheelIcon, HighlightIcon } from \"@sanity/icons\";\nimport { defineField } from \"sanity\";\nimport { styled } from \"styled-components\";\nimport { typeName } from \"../../types\";\n\ntype ColorAnnotationOptions = {\n renderValue?: (value: string | undefined) => string | undefined;\n};\n\nconst ColorText = styled.span<{ $color?: string }>`\n & > span {\n background-color: inherit;\n border-bottom: unset;\n color: ${({ $color = \"inherit\" }) => $color};\n }\n`;\n\nfunction defaultResolveColor(value: string | undefined) {\n return value;\n}\n\nfunction createTextColorAnnotation(options?: ColorAnnotationOptions) {\n const renderValue = options?.renderValue ?? defaultResolveColor;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.textColor`,\n title: \"Text Color\",\n icon: ColorWheelIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const value = renderValue(props.value?.color);\n return <ColorText $color={value}>{props.renderDefault(props)}</ColorText>;\n },\n },\n });\n}\n\nconst ColorBg = styled.span<{ $color?: string }>`\n & > span {\n background-color: ${({ $color = \"inherit\" }) => $color};\n border-bottom: unset;\n color: inherit;\n }\n`;\n\nfunction createHighlightColorAnnotation(options?: ColorAnnotationOptions) {\n const renderValue = options?.renderValue ?? defaultResolveColor;\n\n return defineField({\n type: \"object\",\n name: `${typeName}.annotation.highlightColor`,\n title: \"Highlight Color\",\n icon: HighlightIcon,\n fields: [defineField({ name: \"color\", type: \"wild.color\" })],\n components: {\n annotation: (props) => {\n const value = renderValue(props.value?.color);\n return <ColorBg $color={value}>{props.renderDefault(props)}</ColorBg>;\n },\n },\n });\n}\n\nexport { createTextColorAnnotation, createHighlightColorAnnotation, type ColorAnnotationOptions };\n","import { LinkIcon } from \"@sanity/icons\";\nimport { defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const link = defineField({\n type: \"wild.link\",\n name: `${typeName}.annotation.link`,\n title: \"Link\",\n icon: LinkIcon,\n options: {\n collapsed: false,\n collapsible: false,\n },\n});\n","import { type ColorAnnotationOptions, createHighlightColorAnnotation, createTextColorAnnotation } from \"./color\";\nimport { link } from \"./link\";\n\n/** @public */\nfunction createAnnotations(options?: { textColor?: ColorAnnotationOptions; highlightColor?: ColorAnnotationOptions }) {\n return [link, createTextColorAnnotation(options?.textColor), createHighlightColorAnnotation(options?.highlightColor)] as const;\n}\n\nexport { createAnnotations };\n","import { BoldIcon, CodeIcon, ItalicIcon } from \"@sanity/icons\";\nimport type { BlockDecoratorDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst strong = {\n title: \"Strong\",\n value: `${typeName}.decorator.strong`,\n icon: BoldIcon,\n component: ({ children }) => <strong>{children}</strong>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst em = {\n title: \"Emphasis\",\n value: `${typeName}.decorator.em`,\n icon: ItalicIcon,\n component: ({ children }) => <em>{children}</em>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst code = {\n title: \"Code\",\n value: `${typeName}.decorator.code`,\n icon: CodeIcon,\n component: ({ children }) => <code>{children}</code>,\n} as const satisfies BlockDecoratorDefinition;\n\nconst sup = {\n title: \"Sup\",\n value: `${typeName}.decorator.sup`,\n icon: () => <sup>[1]</sup>,\n component: ({ children }) => <sup style={{ verticalAlign: \"super\" }}>{children}</sup>,\n} as const satisfies BlockDecoratorDefinition;\n\n/** @public */\nfunction createDecorators() {\n return [strong, em, code, sup] as const;\n}\n\nexport { createDecorators };\n","import { OlistIcon, UlistIcon } from \"@sanity/icons\";\nimport type { BlockListDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst bullet = {\n title: \"Bullet\",\n value: `${typeName}.list.bullet`,\n icon: UlistIcon,\n} as const satisfies BlockListDefinition;\n\nconst number = {\n title: \"Number\",\n value: `${typeName}.list.number`,\n icon: OlistIcon,\n} as const satisfies BlockListDefinition;\n\n/** @public */\nfunction createLists() {\n return [bullet, number] as const;\n}\n\nexport { createLists };\n","import * as React from \"react\";\nimport { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\ntype IconSpanOptions = {\n renderValuePreview?: (value?: string) => React.ReactNode;\n};\n\nfunction defaultRenderIconPreview(value?: React.ReactNode) {\n if (React.isValidElement(value)) return value;\n return (\n <span role=\"img\" className=\"inline-block size-[1em] shrink-0 text-current\" title={typeof value === \"string\" ? value : \"Icon\"}>\n 🧿\n </span>\n );\n}\n\nfunction createIconSpan(options?: IconSpanOptions) {\n const renderValuePreview = options?.renderValuePreview;\n\n return defineArrayMember({\n name: `${typeName}.span.icon`,\n type: \"object\",\n title: \"Icon\",\n description: \"Insert an icon.\",\n icon: () => <>🧿</>,\n fields: [defineField({ name: \"icon\", type: \"wild.icon\" })],\n components: {\n // This is the inline-preview in the PortableText editor.\n // It gets its props from the prepare function below.\n preview: (props) => {\n return React.isValidElement(props.media) ? props.media : props.fallbackTitle;\n },\n },\n preview: {\n select: {\n icon: \"icon\",\n },\n prepare({ icon }) {\n return {\n media: renderValuePreview?.(icon) ?? defaultRenderIconPreview(icon),\n };\n },\n },\n });\n}\n\nexport { createIconSpan, type IconSpanOptions };\n","import { defineArrayMember, defineField } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nexport const media = defineArrayMember({\n name: `${typeName}.span.media`,\n type: \"object\",\n title: \"Inline Media\",\n description: \"Embed inline video or image content.\",\n icon: () => <>🫧</>,\n fields: [\n defineField({\n name: \"media\",\n type: \"wild.media\",\n options: {\n inline: true,\n },\n }),\n ],\n components: {\n // This is the inline-preview in the PortableText editor.\n preview: (props) => {\n const icons = {\n video: <>🎥</>,\n image: <>🖼️</>,\n motion: <>🌀</>,\n };\n\n // @ts-expect-error: It gets its props from the prepare function below.\n return icons[props.kind as keyof typeof icons] || <>🖼️</>;\n },\n },\n preview: {\n select: {\n kind: \"media.kind\",\n },\n },\n});\n","import { createIconSpan, type IconSpanOptions } from \"./icon\";\nimport { media } from \"./media\";\n\n/** @public */\nfunction createSpans(options?: { icon?: IconSpanOptions }) {\n return [createIconSpan(options?.icon), media] as const;\n}\n\nexport { createSpans };\n","import type { BlockStyleDefinition } from \"sanity\";\nimport { typeName } from \"../../types\";\n\nconst h2 = {\n title: \"Heading 2\",\n value: `${typeName}.style.h2`,\n component: ({ children }) => (\n <h2\n style={{\n fontSize: \"2.0625rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(41 / 33)\",\n }}\n >\n {children}\n </h2>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h3 = {\n title: \"Heading 3\",\n value: `${typeName}.style.h3`,\n component: ({ children }) => (\n <h3\n style={{\n fontSize: \"1.6875rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(35 / 27)\",\n }}\n >\n {children}\n </h3>\n ),\n} as const satisfies BlockStyleDefinition;\n\nconst h4 = {\n title: \"Heading 4\",\n value: `${typeName}.style.h4`,\n component: ({ children }) => (\n <h4\n style={{\n fontSize: \"1.3125rem\",\n fontWeight: \"700\",\n lineHeight: \"calc(29 / 21)\",\n }}\n >\n {children}\n </h4>\n ),\n} as const satisfies BlockStyleDefinition;\n\n/** @public */\nfunction createStyles() {\n return [h2, h3, h4] as const;\n}\n\nexport { createStyles };\n"],"names":["ColorText","styled","span","$color","defaultResolveColor","value","createTextColorAnnotation","options","renderValue","defineField","type","name","typeName","title","icon","ColorWheelIcon","fields","components","annotation","props","color","renderDefault","ColorBg","createHighlightColorAnnotation","HighlightIcon","link","LinkIcon","collapsed","collapsible","createAnnotations","textColor","highlightColor","strong","BoldIcon","component","children","em","ItalicIcon","code","CodeIcon","sup","verticalAlign","createDecorators","bullet","UlistIcon","number","OlistIcon","createLists","defaultRenderIconPreview","React","isValidElement","createIconSpan","renderValuePreview","defineArrayMember","description","preview","media","fallbackTitle","select","prepare","inline","video","image","motion","kind","createSpans","h2","fontSize","fontWeight","lineHeight","h3","h4","createStyles"],"mappings":";;;;;;AASA,MAAMA,YAAYC,OAAOC;AAAAA;AAAAA;AAAAA;AAAAA,aAIZ,CAAC;AAAA,EAAEC,SAAS;AAAU,MAAMA,MAAM;AAAA;AAAA;AAI/C,SAASC,oBAAoBC,OAA2B;AACtD,SAAOA;AACT;AAEA,SAASC,0BAA0BC,SAAkC;AACnE,QAAMC,cAAcD,SAASC,eAAeJ;AAE5C,SAAOK,YAAY;AAAA,IACjBC,MAAM;AAAA,IACNC,MAAM,GAAGC,QAAQ;AAAA,IACjBC,OAAO;AAAA,IACPC,MAAMC;AAAAA,IACNC,QAAQ,CAACP,YAAY;AAAA,MAAEE,MAAM;AAAA,MAASD,MAAM;AAAA,IAAA,CAAc,CAAC;AAAA,IAC3DO,YAAY;AAAA,MACVC,YAAaC,CAAAA,UAAU;AACrB,cAAMd,QAAQG,YAAYW,MAAMd,OAAOe,KAAK;AAC5C,mCAAQ,WAAA,EAAU,QAAQf,OAAQc,UAAAA,MAAME,cAAcF,KAAK,GAAE;AAAA,MAC/D;AAAA,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AA,EACR;AAEJ,CAAC;AChCD,SAASC,YAAY1D,SAAsC;AACzD,SAAO,CAAC4C,eAAe5C,SAASO,IAAI,GAAG0C,KAAK;AAC9C;ACHA,MAAMU,KAAK;AAAA,EACTrD,OAAO;AAAA,EACPR,OAAO,GAAGO,QAAQ;AAAA,EAClBsB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZ,oBAAC,MAAA,EACC,OAAO;AAAA,IACLgC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGblC,SAAAA,CACH;AAEJ,GAEMmC,KAAK;AAAA,EACTzD,OAAO;AAAA,EACPR,OAAO,GAAGO,QAAQ;AAAA,EAClBsB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZ,oBAAC,MAAA,EACC,OAAO;AAAA,IACLgC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGblC,SAAAA,CACH;AAEJ,GAEMoC,KAAK;AAAA,EACT1D,OAAO;AAAA,EACPR,OAAO,GAAGO,QAAQ;AAAA,EAClBsB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZ,oBAAC,MAAA,EACC,OAAO;AAAA,IACLgC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGblC,SAAAA,CACH;AAEJ;AAGA,SAASqC,eAAe;AACtB,SAAO,CAACN,IAAII,IAAIC,EAAE;AACpB;"}
package/dist/utils.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as sanity107 from "sanity";
1
+ import * as sanity92 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<sanity92.ArrayOfEntry<ObjectDefinition>, "preview"> & {
11
+ preview?: sanity92.PreviewConfig<{
12
12
  [x: string]: string;
13
13
  }, Record<string, string>> | undefined;
14
- } & sanity107.WidenValidation & sanity107.WidenInitialValue;
14
+ } & sanity92.WidenValidation & sanity92.WidenInitialValue;
15
15
  /**
16
16
  * Reshapes the list kind of an array field.
17
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madebywild/sanity-richtext-field",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "UNLICENSED",
@@ -53,8 +53,8 @@
53
53
  "dependencies": {
54
54
  "ts-deepmerge": "^7.0.3",
55
55
  "@madebywild/sanity-media-field": "1.0.0",
56
- "@madebywild/sanity-utils": "1.0.0",
57
- "@madebywild/sanity-quote-field": "1.0.1"
56
+ "@madebywild/sanity-quote-field": "1.0.2",
57
+ "@madebywild/sanity-utils": "1.0.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@sanity/icons": "^3.7.4",
@@ -1,32 +1,26 @@
1
1
  import { ColorWheelIcon, HighlightIcon } from "@sanity/icons";
2
- import { type BlockAnnotationProps, defineField } from "sanity";
2
+ import { defineField } from "sanity";
3
3
  import { styled } from "styled-components";
4
4
  import { typeName } from "../../types";
5
5
 
6
6
  type ColorAnnotationOptions = {
7
- resolveColor?: (value: unknown) => string | undefined;
8
- renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;
7
+ renderValue?: (value: string | undefined) => string | undefined;
9
8
  };
10
9
 
11
- const ColorText = styled.span<{ color?: string }>`
10
+ const ColorText = styled.span<{ $color?: string }>`
12
11
  & > span {
13
12
  background-color: inherit;
14
13
  border-bottom: unset;
15
- color: ${({ color = "inherit" }) => color};
14
+ color: ${({ $color = "inherit" }) => $color};
16
15
  }
17
16
  `;
18
17
 
19
- function defaultResolveColor(value: unknown) {
20
- if (typeof value === "string") return value;
21
- if (value && typeof value === "object" && "value" in value && typeof value.value === "string") {
22
- return value.value;
23
- }
24
- return undefined;
18
+ function defaultResolveColor(value: string | undefined) {
19
+ return value;
25
20
  }
26
21
 
27
22
  function createTextColorAnnotation(options?: ColorAnnotationOptions) {
28
- const resolveColor = options?.resolveColor ?? defaultResolveColor;
29
- const renderAnnotation = options?.renderAnnotation;
23
+ const renderValue = options?.renderValue ?? defaultResolveColor;
30
24
 
31
25
  return defineField({
32
26
  type: "object",
@@ -36,25 +30,23 @@ function createTextColorAnnotation(options?: ColorAnnotationOptions) {
36
30
  fields: [defineField({ name: "color", type: "wild.color" })],
37
31
  components: {
38
32
  annotation: (props) => {
39
- const color = resolveColor(props.value?.color);
40
- if (renderAnnotation) return renderAnnotation(props, color);
41
- return <ColorText color={color}>{props.renderDefault(props)}</ColorText>;
33
+ const value = renderValue(props.value?.color);
34
+ return <ColorText $color={value}>{props.renderDefault(props)}</ColorText>;
42
35
  },
43
36
  },
44
37
  });
45
38
  }
46
39
 
47
- const ColorBg = styled.span<{ color?: string }>`
40
+ const ColorBg = styled.span<{ $color?: string }>`
48
41
  & > span {
49
- background-color: ${({ color = "inherit" }) => color};
42
+ background-color: ${({ $color = "inherit" }) => $color};
50
43
  border-bottom: unset;
51
44
  color: inherit;
52
45
  }
53
46
  `;
54
47
 
55
48
  function createHighlightColorAnnotation(options?: ColorAnnotationOptions) {
56
- const resolveColor = options?.resolveColor ?? defaultResolveColor;
57
- const renderAnnotation = options?.renderAnnotation;
49
+ const renderValue = options?.renderValue ?? defaultResolveColor;
58
50
 
59
51
  return defineField({
60
52
  type: "object",
@@ -64,9 +56,8 @@ function createHighlightColorAnnotation(options?: ColorAnnotationOptions) {
64
56
  fields: [defineField({ name: "color", type: "wild.color" })],
65
57
  components: {
66
58
  annotation: (props) => {
67
- const color = resolveColor(props.value?.color);
68
- if (renderAnnotation) return renderAnnotation(props, color);
69
- return <ColorBg color={color}>{props.renderDefault(props)}</ColorBg>;
59
+ const value = renderValue(props.value?.color);
60
+ return <ColorBg $color={value}>{props.renderDefault(props)}</ColorBg>;
70
61
  },
71
62
  },
72
63
  });
@@ -3,19 +3,20 @@ import { defineArrayMember, defineField } from "sanity";
3
3
  import { typeName } from "../../types";
4
4
 
5
5
  type IconSpanOptions = {
6
- renderPreview?: (value?: string) => React.ReactNode;
6
+ renderValuePreview?: (value?: string) => React.ReactNode;
7
7
  };
8
8
 
9
- function defaultRenderIconPreview(value?: string) {
9
+ function defaultRenderIconPreview(value?: React.ReactNode) {
10
+ if (React.isValidElement(value)) return value;
10
11
  return (
11
- <span role="img" className="inline-block size-[1em] shrink-0 text-current" title={value ?? "Icon"}>
12
+ <span role="img" className="inline-block size-[1em] shrink-0 text-current" title={typeof value === "string" ? value : "Icon"}>
12
13
  🧿
13
14
  </span>
14
15
  );
15
16
  }
16
17
 
17
18
  function createIconSpan(options?: IconSpanOptions) {
18
- const renderPreview = options?.renderPreview ?? defaultRenderIconPreview;
19
+ const renderValuePreview = options?.renderValuePreview;
19
20
 
20
21
  return defineArrayMember({
21
22
  name: `${typeName}.span.icon`,
@@ -37,7 +38,7 @@ function createIconSpan(options?: IconSpanOptions) {
37
38
  },
38
39
  prepare({ icon }) {
39
40
  return {
40
- media: renderPreview(icon),
41
+ media: renderValuePreview?.(icon) ?? defaultRenderIconPreview(icon),
41
42
  };
42
43
  },
43
44
  },