@madebywild/sanity-richtext-field 2.0.0 → 3.1.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 +21 -53
- package/dist/blocks/media-grid-block.d.ts +4 -4
- package/dist/blocks/media-only-block.d.cts +4 -4
- package/dist/blocks/media-only-block.d.ts +4 -4
- package/dist/blocks/media-slider-block.d.cts +4 -4
- package/dist/blocks/media-slider-block.d.ts +4 -4
- package/dist/blocks/quote-block.cjs +1 -1
- package/dist/blocks/quote-block.cjs.map +1 -1
- package/dist/blocks/quote-block.d.cts +4 -4
- package/dist/blocks/quote-block.d.ts +4 -4
- package/dist/blocks/quote-block.js +1 -1
- package/dist/blocks/quote-block.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/parts.cjs +12 -11
- package/dist/parts.cjs.map +1 -1
- package/dist/parts.d.cts +2 -2
- package/dist/parts.d.ts +16 -16
- package/dist/parts.js +8 -11
- package/dist/parts.js.map +1 -1
- package/dist/utils.d.cts +4 -4
- package/package.json +2 -2
- package/src/blocks/quote-block.tsx +1 -1
- package/src/parts/annotations/color.tsx +11 -7
- package/src/parts/spans/icon.tsx +3 -3
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,61 +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: "
|
|
24
|
+
name: "customBlock",
|
|
31
25
|
type: "object",
|
|
32
|
-
|
|
33
|
-
|
|
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()
|
|
46
|
-
styles: [...createStyles()
|
|
47
|
-
lists: [...createLists()
|
|
48
|
-
decorators: [...createDecorators()
|
|
49
|
-
annotations: [...createAnnotations()
|
|
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) => getColor(value)?.cssVar,
|
|
62
|
-
},
|
|
63
|
-
highlightColor: {
|
|
64
|
-
renderValue: (value) => getColor(value)?.cssVar,
|
|
65
|
-
},
|
|
66
|
-
}),
|
|
67
|
-
],
|
|
68
|
-
spans: [
|
|
69
|
-
...createSpans({
|
|
70
|
-
icon: {
|
|
71
|
-
renderValuePreview: (value) => <Icon name={value as IconName} />,
|
|
72
|
-
},
|
|
35
|
+
spans: [...createSpans()],
|
|
36
|
+
styles: [...createStyles()],
|
|
37
|
+
lists: [...createLists()],
|
|
38
|
+
decorators: [...createDecorators()],
|
|
39
|
+
annotations: [...createAnnotations()],
|
|
73
40
|
}),
|
|
74
41
|
],
|
|
75
42
|
});
|
|
@@ -78,18 +45,19 @@ wildSanityRichtextFieldPlugin({
|
|
|
78
45
|
## Use in Schema
|
|
79
46
|
|
|
80
47
|
```ts
|
|
48
|
+
import { defineField } from "sanity";
|
|
49
|
+
|
|
81
50
|
defineField({
|
|
82
51
|
name: "body",
|
|
83
52
|
type: "wild.richtext",
|
|
84
53
|
options: {
|
|
85
|
-
|
|
86
|
-
preset: "full",
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
allowedParts: ["wild.richtext.
|
|
91
|
-
|
|
92
|
-
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"],
|
|
93
61
|
},
|
|
94
62
|
});
|
|
95
63
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity69.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity69.WidenValidation & sanity69.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity65.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity65.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity65.WidenValidation & sanity65.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity61.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity61.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity61.WidenValidation & sanity61.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity61.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity61.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity61.WidenValidation & sanity61.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity65.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity65.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity65.WidenValidation & sanity65.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -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,
|
|
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
|
|
1
|
+
import * as sanity73 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<
|
|
13
|
-
preview?:
|
|
12
|
+
} & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
13
|
+
preview?: sanity73.PreviewConfig<{
|
|
14
14
|
[x: string]: string;
|
|
15
15
|
}, Record<string, string>> | undefined;
|
|
16
|
-
} &
|
|
16
|
+
} & sanity73.WidenValidation & sanity73.WidenInitialValue;
|
|
17
17
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as sanity73 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<
|
|
13
|
-
preview?:
|
|
12
|
+
} & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
13
|
+
preview?: sanity73.PreviewConfig<{
|
|
14
14
|
[x: string]: string;
|
|
15
15
|
}, Record<string, string>> | undefined;
|
|
16
|
-
} &
|
|
16
|
+
} & sanity73.WidenValidation & sanity73.WidenInitialValue;
|
|
17
17
|
export { createBlock };
|
|
@@ -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,
|
|
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
|
|
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:
|
|
89
|
+
declare const wildSanityRichtextFieldPlugin: sanity60.Plugin<PluginConfig>;
|
|
90
90
|
export { type FieldOptions, type PluginConfig, typeName, wildSanityRichtextFieldPlugin };
|
package/dist/parts.cjs
CHANGED
|
@@ -26,11 +26,8 @@ const ColorText = styledComponents.styled.span`
|
|
|
26
26
|
}) => $color};
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
|
-
function defaultResolveColor(value) {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
29
|
function createTextColorAnnotation(options) {
|
|
33
|
-
const renderValue = options?.renderValue
|
|
30
|
+
const renderValue = options?.renderValue;
|
|
34
31
|
return sanity.defineField({
|
|
35
32
|
type: "object",
|
|
36
33
|
name: `${types.typeName}.annotation.textColor`,
|
|
@@ -42,8 +39,10 @@ function createTextColorAnnotation(options) {
|
|
|
42
39
|
})],
|
|
43
40
|
components: {
|
|
44
41
|
annotation: (props) => {
|
|
45
|
-
const value =
|
|
46
|
-
|
|
42
|
+
const value = props.value?.color;
|
|
43
|
+
if (renderValue) return renderValue(value, props);
|
|
44
|
+
const resolvedValue = value;
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ColorText, { $color: resolvedValue, children: props.renderDefault(props) });
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
});
|
|
@@ -58,7 +57,7 @@ const ColorBg = styledComponents.styled.span`
|
|
|
58
57
|
}
|
|
59
58
|
`;
|
|
60
59
|
function createHighlightColorAnnotation(options) {
|
|
61
|
-
const renderValue = options?.renderValue
|
|
60
|
+
const renderValue = options?.renderValue;
|
|
62
61
|
return sanity.defineField({
|
|
63
62
|
type: "object",
|
|
64
63
|
name: `${types.typeName}.annotation.highlightColor`,
|
|
@@ -70,8 +69,10 @@ function createHighlightColorAnnotation(options) {
|
|
|
70
69
|
})],
|
|
71
70
|
components: {
|
|
72
71
|
annotation: (props) => {
|
|
73
|
-
const value =
|
|
74
|
-
|
|
72
|
+
const value = props.value?.color;
|
|
73
|
+
if (renderValue) return renderValue(value, props);
|
|
74
|
+
const resolvedValue = value;
|
|
75
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ColorBg, { $color: resolvedValue, children: props.renderDefault(props) });
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
});
|
|
@@ -139,7 +140,7 @@ function defaultRenderIconPreview(value) {
|
|
|
139
140
|
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}" });
|
|
140
141
|
}
|
|
141
142
|
function createIconSpan(options) {
|
|
142
|
-
const
|
|
143
|
+
const renderValue = options?.renderValue;
|
|
143
144
|
return sanity.defineArrayMember({
|
|
144
145
|
name: `${types.typeName}.span.icon`,
|
|
145
146
|
type: "object",
|
|
@@ -163,7 +164,7 @@ function createIconSpan(options) {
|
|
|
163
164
|
icon
|
|
164
165
|
}) {
|
|
165
166
|
return {
|
|
166
|
-
media:
|
|
167
|
+
media: renderValue?.(icon) ?? defaultRenderIconPreview(icon)
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
170
|
}
|
package/dist/parts.cjs.map
CHANGED
|
@@ -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 { 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,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,MACZC,2BAAAA,IAAC,MAAA,EACC,OAAO;AAAA,IACLiC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGbpC,SAAAA,CACH;AAEJ,GAEMsC,KAAK;AAAA,EACT5D,OAAO;AAAA,EACPR,OAAO,GAAGO,MAAAA,QAAQ;AAAA,EAClBsB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZC,2BAAAA,IAAC,MAAA,EACC,OAAO;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;;;;;;;"}
|
|
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, props: BlockAnnotationProps) => React.ReactNode;\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;\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 = props.value?.color;\n if (renderValue) return renderValue(value, props);\n const resolvedValue = defaultResolveColor(value);\n return <ColorText $color={resolvedValue}>{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;\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 = props.value?.color;\n if (renderValue) return renderValue(value, props);\n const resolvedValue = defaultResolveColor(value);\n return <ColorBg $color={resolvedValue}>{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 renderValue?: (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 renderValue = options?.renderValue;\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: renderValue?.(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","createTextColorAnnotation","options","renderValue","defineField","type","name","typeName","title","icon","ColorWheelIcon","fields","components","annotation","props","value","color","resolvedValue","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","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;AAQ/C,SAASC,0BAA0BC,SAAkC;AACnE,QAAMC,cAAcD,SAASC;AAE7B,SAAOC,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,YAAY;AAAA,MACVC,YAAaC,CAAAA,UAAU;AACrB,cAAMC,QAAQD,MAAMC,OAAOC;AAC3B,YAAIb,YAAa,QAAOA,YAAYY,OAAOD,KAAK;AAChD,cAAMG,gBAAoCF;AAC1C,8CAAQ,W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AY;AAAA,EAAA,GAGbnC,SAAAA,CACH;AAEJ;AAGA,SAASsC,eAAe;AACtB,SAAO,CAACN,IAAII,IAAIC,EAAE;AACpB;;;;;;;"}
|
package/dist/parts.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as sanity77 from "sanity";
|
|
2
2
|
import * as react22 from "react";
|
|
3
3
|
type ColorAnnotationOptions = {
|
|
4
|
-
renderValue?: (value: string | undefined) =>
|
|
4
|
+
renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
|
|
5
5
|
};
|
|
6
6
|
/** @public */
|
|
7
7
|
declare function createAnnotations(options?: {
|
|
@@ -64,7 +64,7 @@ declare function createLists(): readonly [{
|
|
|
64
64
|
readonly icon: react22.ForwardRefExoticComponent<Omit<react22.SVGProps<SVGSVGElement>, "ref"> & react22.RefAttributes<SVGSVGElement>>;
|
|
65
65
|
}];
|
|
66
66
|
type IconSpanOptions = {
|
|
67
|
-
|
|
67
|
+
renderValue?: (value?: string) => react22.ReactNode;
|
|
68
68
|
};
|
|
69
69
|
declare function createIconSpan(options?: IconSpanOptions): {
|
|
70
70
|
type: "object";
|
package/dist/parts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as sanity81 from "sanity";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react31 from "react";
|
|
3
3
|
type ColorAnnotationOptions = {
|
|
4
|
-
renderValue?: (value: string | undefined) =>
|
|
4
|
+
renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
|
|
5
5
|
};
|
|
6
6
|
/** @public */
|
|
7
7
|
declare function createAnnotations(options?: {
|
|
@@ -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:
|
|
30
|
+
readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
|
|
31
31
|
readonly component: ({
|
|
32
32
|
children
|
|
33
|
-
}: BlockDecoratorProps) =>
|
|
33
|
+
}: BlockDecoratorProps) => react31.JSX.Element;
|
|
34
34
|
}, {
|
|
35
35
|
readonly title: "Emphasis";
|
|
36
36
|
readonly value: "wild.richtext.decorator.em";
|
|
37
|
-
readonly icon:
|
|
37
|
+
readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
|
|
38
38
|
readonly component: ({
|
|
39
39
|
children
|
|
40
|
-
}: BlockDecoratorProps) =>
|
|
40
|
+
}: BlockDecoratorProps) => react31.JSX.Element;
|
|
41
41
|
}, {
|
|
42
42
|
readonly title: "Code";
|
|
43
43
|
readonly value: "wild.richtext.decorator.code";
|
|
44
|
-
readonly icon:
|
|
44
|
+
readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
|
|
45
45
|
readonly component: ({
|
|
46
46
|
children
|
|
47
|
-
}: BlockDecoratorProps) =>
|
|
47
|
+
}: BlockDecoratorProps) => react31.JSX.Element;
|
|
48
48
|
}, {
|
|
49
49
|
readonly title: "Sup";
|
|
50
50
|
readonly value: "wild.richtext.decorator.sup";
|
|
51
|
-
readonly icon: () =>
|
|
51
|
+
readonly icon: () => react31.JSX.Element;
|
|
52
52
|
readonly component: ({
|
|
53
53
|
children
|
|
54
|
-
}: BlockDecoratorProps) =>
|
|
54
|
+
}: BlockDecoratorProps) => react31.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:
|
|
60
|
+
readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
|
|
61
61
|
}, {
|
|
62
62
|
readonly title: "Number";
|
|
63
63
|
readonly value: "wild.richtext.list.number";
|
|
64
|
-
readonly icon:
|
|
64
|
+
readonly icon: react31.ForwardRefExoticComponent<Omit<react31.SVGProps<SVGSVGElement>, "ref"> & react31.RefAttributes<SVGSVGElement>>;
|
|
65
65
|
}];
|
|
66
66
|
type IconSpanOptions = {
|
|
67
|
-
|
|
67
|
+
renderValue?: (value?: string) => react31.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) =>
|
|
101
|
+
}: BlockStyleProps) => react31.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) =>
|
|
107
|
+
}: BlockStyleProps) => react31.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) =>
|
|
113
|
+
}: BlockStyleProps) => react31.JSX.Element;
|
|
114
114
|
}];
|
|
115
115
|
export { createAnnotations, createDecorators, createIconSpan, createLists, createSpans, createStyles };
|
package/dist/parts.js
CHANGED
|
@@ -13,11 +13,8 @@ const ColorText = styled.span`
|
|
|
13
13
|
}) => $color};
|
|
14
14
|
}
|
|
15
15
|
`;
|
|
16
|
-
function defaultResolveColor(value) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
16
|
function createTextColorAnnotation(options) {
|
|
20
|
-
const renderValue = options?.renderValue
|
|
17
|
+
const renderValue = options?.renderValue;
|
|
21
18
|
return defineField({
|
|
22
19
|
type: "object",
|
|
23
20
|
name: `${typeName}.annotation.textColor`,
|
|
@@ -29,8 +26,8 @@ function createTextColorAnnotation(options) {
|
|
|
29
26
|
})],
|
|
30
27
|
components: {
|
|
31
28
|
annotation: (props) => {
|
|
32
|
-
const value =
|
|
33
|
-
return /* @__PURE__ */ jsx(ColorText, { $color: value, children: props.renderDefault(props) });
|
|
29
|
+
const value = props.value?.color;
|
|
30
|
+
return renderValue ? renderValue(value, props) : /* @__PURE__ */ jsx(ColorText, { $color: value, children: props.renderDefault(props) });
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
});
|
|
@@ -45,7 +42,7 @@ const ColorBg = styled.span`
|
|
|
45
42
|
}
|
|
46
43
|
`;
|
|
47
44
|
function createHighlightColorAnnotation(options) {
|
|
48
|
-
const renderValue = options?.renderValue
|
|
45
|
+
const renderValue = options?.renderValue;
|
|
49
46
|
return defineField({
|
|
50
47
|
type: "object",
|
|
51
48
|
name: `${typeName}.annotation.highlightColor`,
|
|
@@ -57,8 +54,8 @@ function createHighlightColorAnnotation(options) {
|
|
|
57
54
|
})],
|
|
58
55
|
components: {
|
|
59
56
|
annotation: (props) => {
|
|
60
|
-
const value =
|
|
61
|
-
return /* @__PURE__ */ jsx(ColorBg, { $color: value, children: props.renderDefault(props) });
|
|
57
|
+
const value = props.value?.color;
|
|
58
|
+
return renderValue ? renderValue(value, props) : /* @__PURE__ */ jsx(ColorBg, { $color: value, children: props.renderDefault(props) });
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
});
|
|
@@ -126,7 +123,7 @@ function defaultRenderIconPreview(value) {
|
|
|
126
123
|
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}" });
|
|
127
124
|
}
|
|
128
125
|
function createIconSpan(options) {
|
|
129
|
-
const
|
|
126
|
+
const renderValue = options?.renderValue;
|
|
130
127
|
return defineArrayMember({
|
|
131
128
|
name: `${typeName}.span.icon`,
|
|
132
129
|
type: "object",
|
|
@@ -150,7 +147,7 @@ function createIconSpan(options) {
|
|
|
150
147
|
icon
|
|
151
148
|
}) {
|
|
152
149
|
return {
|
|
153
|
-
media:
|
|
150
|
+
media: renderValue?.(icon) ?? defaultRenderIconPreview(icon)
|
|
154
151
|
};
|
|
155
152
|
}
|
|
156
153
|
}
|
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 { 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,IAAA;AAAA,EACF,CACD;AACH;AAEA,MAAMG,UAAUrB,OAAOC;AAAAA;AAAAA,wBAEC,CAAC;AAAA,EAAEC,SAAS;AAAU,MAAMA,MAAM;AAAA;AAAA;AAAA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ACTrD,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;"}
|
|
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, props: BlockAnnotationProps) => React.ReactNode;\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;\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 = props.value?.color;\n if (renderValue) return renderValue(value, props);\n const resolvedValue = defaultResolveColor(value);\n return <ColorText $color={resolvedValue}>{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;\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 = props.value?.color;\n if (renderValue) return renderValue(value, props);\n const resolvedValue = defaultResolveColor(value);\n return <ColorBg $color={resolvedValue}>{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 renderValue?: (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 renderValue = options?.renderValue;\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: renderValue?.(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","createTextColorAnnotation","options","renderValue","defineField","type","name","typeName","title","icon","ColorWheelIcon","fields","components","annotation","props","value","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","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;AAQ/C,SAASC,0BAA0BC,SAAkC;AACnE,QAAMC,cAAcD,SAASC;AAE7B,SAAOC,YAAY;AAAA,IACjBC,MAAM;AAAA,IACNC,MAAM,GAAGC,QAAQ;AAAA,IACjBC,OAAO;AAAA,IACPC,MAAMC;AAAAA,IACNC,QAAQ,CAACP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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as sanity107 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<
|
|
11
|
-
preview?:
|
|
10
|
+
} & Omit<sanity107.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
11
|
+
preview?: sanity107.PreviewConfig<{
|
|
12
12
|
[x: string]: string;
|
|
13
13
|
}, Record<string, string>> | undefined;
|
|
14
|
-
} &
|
|
14
|
+
} & sanity107.WidenValidation & sanity107.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": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"ts-deepmerge": "^7.0.3",
|
|
55
|
+
"@madebywild/sanity-quote-field": "1.1.0",
|
|
55
56
|
"@madebywild/sanity-media-field": "1.0.0",
|
|
56
|
-
"@madebywild/sanity-quote-field": "1.0.2",
|
|
57
57
|
"@madebywild/sanity-utils": "1.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -34,7 +34,7 @@ function createBlock({ name, fields = [], ...props }: Options = {}) {
|
|
|
34
34
|
},
|
|
35
35
|
prepare({ quote }) {
|
|
36
36
|
return {
|
|
37
|
-
subtitle: quote ? createExcerptFromPortableText(quote,
|
|
37
|
+
subtitle: quote ? createExcerptFromPortableText(quote, 35) : undefined,
|
|
38
38
|
};
|
|
39
39
|
},
|
|
40
40
|
},
|
|
@@ -4,7 +4,7 @@ import { styled } from "styled-components";
|
|
|
4
4
|
import { typeName } from "../../types";
|
|
5
5
|
|
|
6
6
|
type ColorAnnotationOptions = {
|
|
7
|
-
renderValue?: (value: string | undefined) =>
|
|
7
|
+
renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const ColorText = styled.span<{ $color?: string }>`
|
|
@@ -20,7 +20,7 @@ function defaultResolveColor(value: string | undefined) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function createTextColorAnnotation(options?: ColorAnnotationOptions) {
|
|
23
|
-
const renderValue = options?.renderValue
|
|
23
|
+
const renderValue = options?.renderValue;
|
|
24
24
|
|
|
25
25
|
return defineField({
|
|
26
26
|
type: "object",
|
|
@@ -30,8 +30,10 @@ function createTextColorAnnotation(options?: ColorAnnotationOptions) {
|
|
|
30
30
|
fields: [defineField({ name: "color", type: "wild.color" })],
|
|
31
31
|
components: {
|
|
32
32
|
annotation: (props) => {
|
|
33
|
-
const value =
|
|
34
|
-
return
|
|
33
|
+
const value = props.value?.color;
|
|
34
|
+
if (renderValue) return renderValue(value, props);
|
|
35
|
+
const resolvedValue = defaultResolveColor(value);
|
|
36
|
+
return <ColorText $color={resolvedValue}>{props.renderDefault(props)}</ColorText>;
|
|
35
37
|
},
|
|
36
38
|
},
|
|
37
39
|
});
|
|
@@ -46,7 +48,7 @@ const ColorBg = styled.span<{ $color?: string }>`
|
|
|
46
48
|
`;
|
|
47
49
|
|
|
48
50
|
function createHighlightColorAnnotation(options?: ColorAnnotationOptions) {
|
|
49
|
-
const renderValue = options?.renderValue
|
|
51
|
+
const renderValue = options?.renderValue;
|
|
50
52
|
|
|
51
53
|
return defineField({
|
|
52
54
|
type: "object",
|
|
@@ -56,8 +58,10 @@ function createHighlightColorAnnotation(options?: ColorAnnotationOptions) {
|
|
|
56
58
|
fields: [defineField({ name: "color", type: "wild.color" })],
|
|
57
59
|
components: {
|
|
58
60
|
annotation: (props) => {
|
|
59
|
-
const value =
|
|
60
|
-
return
|
|
61
|
+
const value = props.value?.color;
|
|
62
|
+
if (renderValue) return renderValue(value, props);
|
|
63
|
+
const resolvedValue = defaultResolveColor(value);
|
|
64
|
+
return <ColorBg $color={resolvedValue}>{props.renderDefault(props)}</ColorBg>;
|
|
61
65
|
},
|
|
62
66
|
},
|
|
63
67
|
});
|
package/src/parts/spans/icon.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { defineArrayMember, defineField } from "sanity";
|
|
|
3
3
|
import { typeName } from "../../types";
|
|
4
4
|
|
|
5
5
|
type IconSpanOptions = {
|
|
6
|
-
|
|
6
|
+
renderValue?: (value?: string) => React.ReactNode;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
function defaultRenderIconPreview(value?: React.ReactNode) {
|
|
@@ -16,7 +16,7 @@ function defaultRenderIconPreview(value?: React.ReactNode) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function createIconSpan(options?: IconSpanOptions) {
|
|
19
|
-
const
|
|
19
|
+
const renderValue = options?.renderValue;
|
|
20
20
|
|
|
21
21
|
return defineArrayMember({
|
|
22
22
|
name: `${typeName}.span.icon`,
|
|
@@ -38,7 +38,7 @@ function createIconSpan(options?: IconSpanOptions) {
|
|
|
38
38
|
},
|
|
39
39
|
prepare({ icon }) {
|
|
40
40
|
return {
|
|
41
|
-
media:
|
|
41
|
+
media: renderValue?.(icon) ?? defaultRenderIconPreview(icon),
|
|
42
42
|
};
|
|
43
43
|
},
|
|
44
44
|
},
|