@madebywild/sanity-richtext-field 1.1.0 → 3.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 +7 -3
- package/dist/blocks/media-grid-block.d.cts +4 -4
- 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.d.cts +4 -4
- package/dist/blocks/quote-block.d.ts +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/parts.cjs +17 -18
- package/dist/parts.cjs.map +1 -1
- package/dist/parts.d.cts +17 -19
- package/dist/parts.d.ts +17 -19
- package/dist/parts.js +13 -18
- package/dist/parts.js.map +1 -1
- package/package.json +3 -3
- package/src/parts/annotations/color.tsx +18 -23
- package/src/parts/spans/icon.tsx +6 -5
package/README.md
CHANGED
|
@@ -58,17 +58,21 @@ wildSanityRichtextFieldPlugin({
|
|
|
58
58
|
annotations: [
|
|
59
59
|
...createAnnotations({
|
|
60
60
|
textColor: {
|
|
61
|
-
|
|
61
|
+
renderValue: (value, props) => (
|
|
62
|
+
<span style={{ color: getColor(value)?.cssVar }}>{props.renderDefault(props)}</span>
|
|
63
|
+
),
|
|
62
64
|
},
|
|
63
65
|
highlightColor: {
|
|
64
|
-
|
|
66
|
+
renderValue: (value, props) => (
|
|
67
|
+
<mark style={{ backgroundColor: getColor(value)?.cssVar }}>{props.renderDefault(props)}</mark>
|
|
68
|
+
),
|
|
65
69
|
},
|
|
66
70
|
}),
|
|
67
71
|
],
|
|
68
72
|
spans: [
|
|
69
73
|
...createSpans({
|
|
70
74
|
icon: {
|
|
71
|
-
|
|
75
|
+
renderValue: (value) => <Icon name={value as IconName} />,
|
|
72
76
|
},
|
|
73
77
|
}),
|
|
74
78
|
],
|
|
@@ -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 sanity72 from "sanity";
|
|
2
2
|
import { ObjectDefinition } from "sanity";
|
|
3
3
|
import { FieldOptions } from "@madebywild/sanity-media-field";
|
|
4
4
|
type Options = Omit<Partial<ObjectDefinition>, "type"> & {
|
|
@@ -16,9 +16,9 @@ declare function createBlock({
|
|
|
16
16
|
}?: Options): {
|
|
17
17
|
type: "object";
|
|
18
18
|
name?: string | undefined;
|
|
19
|
-
} & Omit<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity72.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity72.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity72.WidenValidation & sanity72.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity73.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity73.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity73.WidenValidation & sanity73.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as sanity60 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<sanity60.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity60.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity60.WidenValidation & sanity60.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 sanity64 from "sanity";
|
|
2
2
|
import { ObjectDefinition } from "sanity";
|
|
3
3
|
import { FieldOptions } from "@madebywild/sanity-media-field";
|
|
4
4
|
type Options = Omit<Partial<ObjectDefinition>, "type"> & {
|
|
@@ -16,9 +16,9 @@ declare function createBlock({
|
|
|
16
16
|
}?: Options): {
|
|
17
17
|
type: "object";
|
|
18
18
|
name?: string | undefined;
|
|
19
|
-
} & Omit<
|
|
20
|
-
preview?:
|
|
19
|
+
} & Omit<sanity64.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
20
|
+
preview?: sanity64.PreviewConfig<{
|
|
21
21
|
[x: string]: string;
|
|
22
22
|
}, Record<string, string>> | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & sanity64.WidenValidation & sanity64.WidenInitialValue;
|
|
24
24
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as sanity69 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<sanity69.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
13
|
+
preview?: sanity69.PreviewConfig<{
|
|
14
14
|
[x: string]: string;
|
|
15
15
|
}, Record<string, string>> | undefined;
|
|
16
|
-
} &
|
|
16
|
+
} & sanity69.WidenValidation & sanity69.WidenInitialValue;
|
|
17
17
|
export { createBlock };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as sanity68 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<sanity68.ArrayOfEntry<ObjectDefinition>, "preview"> & {
|
|
13
|
+
preview?: sanity68.PreviewConfig<{
|
|
14
14
|
[x: string]: string;
|
|
15
15
|
}, Record<string, string>> | undefined;
|
|
16
|
-
} &
|
|
16
|
+
} & sanity68.WidenValidation & sanity68.WidenInitialValue;
|
|
17
17
|
export { createBlock };
|
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/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as sanity76 from "sanity";
|
|
2
2
|
import { ArrayDefinition, ArrayOfType, ArrayOptions, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition } from "sanity";
|
|
3
3
|
/** @public */
|
|
4
4
|
declare const typeName: "wild.richtext";
|
|
@@ -86,5 +86,5 @@ declare module "sanity" {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
/** @public */
|
|
89
|
-
declare const wildSanityRichtextFieldPlugin:
|
|
89
|
+
declare const wildSanityRichtextFieldPlugin: sanity76.Plugin<PluginConfig>;
|
|
90
90
|
export { type FieldOptions, type PluginConfig, typeName, wildSanityRichtextFieldPlugin };
|
package/dist/parts.cjs
CHANGED
|
@@ -22,17 +22,12 @@ 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
|
-
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;
|
|
33
|
-
}
|
|
34
29
|
function createTextColorAnnotation(options) {
|
|
35
|
-
const
|
|
30
|
+
const renderValue = options?.renderValue;
|
|
36
31
|
return sanity.defineField({
|
|
37
32
|
type: "object",
|
|
38
33
|
name: `${types.typeName}.annotation.textColor`,
|
|
@@ -44,8 +39,10 @@ function createTextColorAnnotation(options) {
|
|
|
44
39
|
})],
|
|
45
40
|
components: {
|
|
46
41
|
annotation: (props) => {
|
|
47
|
-
const
|
|
48
|
-
|
|
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) });
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
});
|
|
@@ -53,14 +50,14 @@ function createTextColorAnnotation(options) {
|
|
|
53
50
|
const ColorBg = styledComponents.styled.span`
|
|
54
51
|
& > span {
|
|
55
52
|
background-color: ${({
|
|
56
|
-
color = "inherit"
|
|
57
|
-
}) => color};
|
|
53
|
+
$color = "inherit"
|
|
54
|
+
}) => $color};
|
|
58
55
|
border-bottom: unset;
|
|
59
56
|
color: inherit;
|
|
60
57
|
}
|
|
61
58
|
`;
|
|
62
59
|
function createHighlightColorAnnotation(options) {
|
|
63
|
-
const
|
|
60
|
+
const renderValue = options?.renderValue;
|
|
64
61
|
return sanity.defineField({
|
|
65
62
|
type: "object",
|
|
66
63
|
name: `${types.typeName}.annotation.highlightColor`,
|
|
@@ -72,8 +69,10 @@ function createHighlightColorAnnotation(options) {
|
|
|
72
69
|
})],
|
|
73
70
|
components: {
|
|
74
71
|
annotation: (props) => {
|
|
75
|
-
const
|
|
76
|
-
|
|
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) });
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
});
|
|
@@ -138,10 +137,10 @@ function createLists() {
|
|
|
138
137
|
return [bullet, number];
|
|
139
138
|
}
|
|
140
139
|
function defaultRenderIconPreview(value) {
|
|
141
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: value
|
|
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}" });
|
|
142
141
|
}
|
|
143
142
|
function createIconSpan(options) {
|
|
144
|
-
const
|
|
143
|
+
const renderValue = options?.renderValue;
|
|
145
144
|
return sanity.defineArrayMember({
|
|
146
145
|
name: `${types.typeName}.span.icon`,
|
|
147
146
|
type: "object",
|
|
@@ -165,7 +164,7 @@ function createIconSpan(options) {
|
|
|
165
164
|
icon
|
|
166
165
|
}) {
|
|
167
166
|
return {
|
|
168
|
-
media:
|
|
167
|
+
media: renderValue?.(icon) ?? defaultRenderIconPreview(icon)
|
|
169
168
|
};
|
|
170
169
|
}
|
|
171
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 { 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,SAAS,OAAOA,MAAMA,SAAU;AACnF,WAAOA,MAAMA;AAGjB;AAEA,SAASC,0BAA0BC,SAAkC;AACnE,QAAMC,eAAeD,SAASC,gBAAgBJ,qBACxCK,mBAAmBF,SAASE;AAElC,SAAOC,mBAAY;AAAA,IACjBC,MAAM;AAAA,IACNC,MAAM,GAAGC,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AAA,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, 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,WAAA,EAAU,QAAQE,eAAgBH,UAAAA,MAAM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EJ;AAGA,SAASsC,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
|
|
3
|
-
import * as react31 from "react";
|
|
2
|
+
import * as react28 from "react";
|
|
4
3
|
type ColorAnnotationOptions = {
|
|
5
|
-
|
|
6
|
-
renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;
|
|
4
|
+
renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
|
|
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.
|
|
13
|
+
} & sanity77.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.richtext" | "wild.quote" | "wild.media" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
|
|
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:
|
|
30
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
33
31
|
readonly component: ({
|
|
34
32
|
children
|
|
35
|
-
}: BlockDecoratorProps) =>
|
|
33
|
+
}: BlockDecoratorProps) => react28.JSX.Element;
|
|
36
34
|
}, {
|
|
37
35
|
readonly title: "Emphasis";
|
|
38
36
|
readonly value: "wild.richtext.decorator.em";
|
|
39
|
-
readonly icon:
|
|
37
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
40
38
|
readonly component: ({
|
|
41
39
|
children
|
|
42
|
-
}: BlockDecoratorProps) =>
|
|
40
|
+
}: BlockDecoratorProps) => react28.JSX.Element;
|
|
43
41
|
}, {
|
|
44
42
|
readonly title: "Code";
|
|
45
43
|
readonly value: "wild.richtext.decorator.code";
|
|
46
|
-
readonly icon:
|
|
44
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
47
45
|
readonly component: ({
|
|
48
46
|
children
|
|
49
|
-
}: BlockDecoratorProps) =>
|
|
47
|
+
}: BlockDecoratorProps) => react28.JSX.Element;
|
|
50
48
|
}, {
|
|
51
49
|
readonly title: "Sup";
|
|
52
50
|
readonly value: "wild.richtext.decorator.sup";
|
|
53
|
-
readonly icon: () =>
|
|
51
|
+
readonly icon: () => react28.JSX.Element;
|
|
54
52
|
readonly component: ({
|
|
55
53
|
children
|
|
56
|
-
}: BlockDecoratorProps) =>
|
|
54
|
+
}: BlockDecoratorProps) => react28.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:
|
|
60
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
63
61
|
}, {
|
|
64
62
|
readonly title: "Number";
|
|
65
63
|
readonly value: "wild.richtext.list.number";
|
|
66
|
-
readonly icon:
|
|
64
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
67
65
|
}];
|
|
68
66
|
type IconSpanOptions = {
|
|
69
|
-
|
|
67
|
+
renderValue?: (value?: string) => react28.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) =>
|
|
101
|
+
}: BlockStyleProps) => react28.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) =>
|
|
107
|
+
}: BlockStyleProps) => react28.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) =>
|
|
113
|
+
}: BlockStyleProps) => react28.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
|
|
3
|
-
import * as react31 from "react";
|
|
2
|
+
import * as react28 from "react";
|
|
4
3
|
type ColorAnnotationOptions = {
|
|
5
|
-
|
|
6
|
-
renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;
|
|
4
|
+
renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
|
|
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
|
-
} & sanity81.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.
|
|
13
|
+
} & sanity81.TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.media" | "wild.richtext" | "wild.quote" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
|
|
16
14
|
preview?: sanity81.PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
17
15
|
} & sanity81.FieldDefinitionBase & sanity81.WidenValidation & sanity81.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:
|
|
30
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
33
31
|
readonly component: ({
|
|
34
32
|
children
|
|
35
|
-
}: BlockDecoratorProps) =>
|
|
33
|
+
}: BlockDecoratorProps) => react28.JSX.Element;
|
|
36
34
|
}, {
|
|
37
35
|
readonly title: "Emphasis";
|
|
38
36
|
readonly value: "wild.richtext.decorator.em";
|
|
39
|
-
readonly icon:
|
|
37
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
40
38
|
readonly component: ({
|
|
41
39
|
children
|
|
42
|
-
}: BlockDecoratorProps) =>
|
|
40
|
+
}: BlockDecoratorProps) => react28.JSX.Element;
|
|
43
41
|
}, {
|
|
44
42
|
readonly title: "Code";
|
|
45
43
|
readonly value: "wild.richtext.decorator.code";
|
|
46
|
-
readonly icon:
|
|
44
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
47
45
|
readonly component: ({
|
|
48
46
|
children
|
|
49
|
-
}: BlockDecoratorProps) =>
|
|
47
|
+
}: BlockDecoratorProps) => react28.JSX.Element;
|
|
50
48
|
}, {
|
|
51
49
|
readonly title: "Sup";
|
|
52
50
|
readonly value: "wild.richtext.decorator.sup";
|
|
53
|
-
readonly icon: () =>
|
|
51
|
+
readonly icon: () => react28.JSX.Element;
|
|
54
52
|
readonly component: ({
|
|
55
53
|
children
|
|
56
|
-
}: BlockDecoratorProps) =>
|
|
54
|
+
}: BlockDecoratorProps) => react28.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:
|
|
60
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
63
61
|
}, {
|
|
64
62
|
readonly title: "Number";
|
|
65
63
|
readonly value: "wild.richtext.list.number";
|
|
66
|
-
readonly icon:
|
|
64
|
+
readonly icon: react28.ForwardRefExoticComponent<Omit<react28.SVGProps<SVGSVGElement>, "ref"> & react28.RefAttributes<SVGSVGElement>>;
|
|
67
65
|
}];
|
|
68
66
|
type IconSpanOptions = {
|
|
69
|
-
|
|
67
|
+
renderValue?: (value?: string) => react28.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) =>
|
|
101
|
+
}: BlockStyleProps) => react28.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) =>
|
|
107
|
+
}: BlockStyleProps) => react28.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) =>
|
|
113
|
+
}: BlockStyleProps) => react28.JSX.Element;
|
|
116
114
|
}];
|
|
117
115
|
export { createAnnotations, createDecorators, createIconSpan, createLists, createSpans, createStyles };
|
package/dist/parts.js
CHANGED
|
@@ -9,17 +9,12 @@ 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
|
-
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;
|
|
20
|
-
}
|
|
21
16
|
function createTextColorAnnotation(options) {
|
|
22
|
-
const
|
|
17
|
+
const renderValue = options?.renderValue;
|
|
23
18
|
return defineField({
|
|
24
19
|
type: "object",
|
|
25
20
|
name: `${typeName}.annotation.textColor`,
|
|
@@ -31,8 +26,8 @@ function createTextColorAnnotation(options) {
|
|
|
31
26
|
})],
|
|
32
27
|
components: {
|
|
33
28
|
annotation: (props) => {
|
|
34
|
-
const
|
|
35
|
-
return
|
|
29
|
+
const value = props.value?.color;
|
|
30
|
+
return renderValue ? renderValue(value, props) : /* @__PURE__ */ jsx(ColorText, { $color: value, children: props.renderDefault(props) });
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
33
|
});
|
|
@@ -40,14 +35,14 @@ function createTextColorAnnotation(options) {
|
|
|
40
35
|
const ColorBg = styled.span`
|
|
41
36
|
& > span {
|
|
42
37
|
background-color: ${({
|
|
43
|
-
color = "inherit"
|
|
44
|
-
}) => color};
|
|
38
|
+
$color = "inherit"
|
|
39
|
+
}) => $color};
|
|
45
40
|
border-bottom: unset;
|
|
46
41
|
color: inherit;
|
|
47
42
|
}
|
|
48
43
|
`;
|
|
49
44
|
function createHighlightColorAnnotation(options) {
|
|
50
|
-
const
|
|
45
|
+
const renderValue = options?.renderValue;
|
|
51
46
|
return defineField({
|
|
52
47
|
type: "object",
|
|
53
48
|
name: `${typeName}.annotation.highlightColor`,
|
|
@@ -59,8 +54,8 @@ function createHighlightColorAnnotation(options) {
|
|
|
59
54
|
})],
|
|
60
55
|
components: {
|
|
61
56
|
annotation: (props) => {
|
|
62
|
-
const
|
|
63
|
-
return
|
|
57
|
+
const value = props.value?.color;
|
|
58
|
+
return renderValue ? renderValue(value, props) : /* @__PURE__ */ jsx(ColorBg, { $color: value, children: props.renderDefault(props) });
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
61
|
});
|
|
@@ -125,10 +120,10 @@ function createLists() {
|
|
|
125
120
|
return [bullet, number];
|
|
126
121
|
}
|
|
127
122
|
function defaultRenderIconPreview(value) {
|
|
128
|
-
return /* @__PURE__ */ jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: value
|
|
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}" });
|
|
129
124
|
}
|
|
130
125
|
function createIconSpan(options) {
|
|
131
|
-
const
|
|
126
|
+
const renderValue = options?.renderValue;
|
|
132
127
|
return defineArrayMember({
|
|
133
128
|
name: `${typeName}.span.icon`,
|
|
134
129
|
type: "object",
|
|
@@ -152,7 +147,7 @@ function createIconSpan(options) {
|
|
|
152
147
|
icon
|
|
153
148
|
}) {
|
|
154
149
|
return {
|
|
155
|
-
media:
|
|
150
|
+
media: renderValue?.(icon) ?? defaultRenderIconPreview(icon)
|
|
156
151
|
};
|
|
157
152
|
}
|
|
158
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 { 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":";;;;;;AAUA,MAAMA,YAAYC,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,SAAS,OAAOA,MAAMA,SAAU;AACnF,WAAOA,MAAMA;AAGjB;AAEA,SAASC,0BAA0BC,SAAkC;AACnE,QAAMC,eAAeD,SAASC,gBAAgBJ,qBACxCK,mBAAmBF,SAASE;AAElC,SAAOC,YAAY;AAAA,IACjBC,MAAM;AAAA,IACNC,MAAM,GAAGC,QAAQ;AAAA,IACjBC,OAAO;AAAA,IACPC,MAAMC;AAAAA,IACNC,QAAQ,CAACP,YAAY;AAAA,MAAEE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{"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,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,eAAIb,cAAoBA,YAAYY,OAAOD,KAAK,wBAExC,WAAA,EAAU,QADwBC,OACAD,UAAAA,MAAMG,cAAcH,KAAK,GAAE;AAAA,MACvE;AAAA,IAAA;AAAA,EACF,CACD;AACH;AAEA,MAAMI,UAAUpB,OAAOC;AAAAA;AAAAA,wBAEC,CAAC;AAAA,EAAEC,SAAS;AAAU,MAAMA,MAAM;AAAA;AAAA;AAAA;AAAA;AAM1D,SAASmB,+BAA+BjB,SAAkC;AACxE,QAAMC,cAAcD,SAASC;AAE7B,SAAOC,YAAY;AAAA,IACjBC,MAAM;AAAA,IACNC,MAAM,GAAGC,QAAQ;AAAA,IACjBC,OAAO;AAAA,IACPC,MAAMW;AAAAA,IACNT,QAAQ,CAACP,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,eAAI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,OAAO;AAAA,IACL+B,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGbjC,SAAAA,CACH;AAEJ,GAEMmC,KAAK;AAAA,EACT1D,OAAO;AAAA,EACPO,OAAO,GAAGR,QAAQ;AAAA,EAClBuB,WAAWA,CAAC;AAAA,IAAEC;AAAAA,EAAAA,MACZ,oBAAC,MAAA,EACC,OAAO;AAAA,IACL+B,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,YAAY;AAAA,EAAA,GAGbjC,SAAAA,CACH;AAEJ;AAGA,SAASoC,eAAe;AACtB,SAAO,CAACN,IAAII,IAAIC,EAAE;AACpB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madebywild/sanity-richtext-field",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.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-
|
|
57
|
-
"@madebywild/sanity-
|
|
56
|
+
"@madebywild/sanity-quote-field": "1.0.3",
|
|
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 {
|
|
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
|
-
|
|
8
|
-
renderAnnotation?: (props: BlockAnnotationProps, color?: string) => React.JSX.Element;
|
|
7
|
+
renderValue?: (value: string | undefined, props: BlockAnnotationProps) => React.ReactNode;
|
|
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:
|
|
20
|
-
|
|
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
|
|
29
|
-
const renderAnnotation = options?.renderAnnotation;
|
|
23
|
+
const renderValue = options?.renderValue;
|
|
30
24
|
|
|
31
25
|
return defineField({
|
|
32
26
|
type: "object",
|
|
@@ -36,25 +30,25 @@ function createTextColorAnnotation(options?: ColorAnnotationOptions) {
|
|
|
36
30
|
fields: [defineField({ name: "color", type: "wild.color" })],
|
|
37
31
|
components: {
|
|
38
32
|
annotation: (props) => {
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
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>;
|
|
42
37
|
},
|
|
43
38
|
},
|
|
44
39
|
});
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
const ColorBg = styled.span<{ color?: string }>`
|
|
42
|
+
const ColorBg = styled.span<{ $color?: string }>`
|
|
48
43
|
& > span {
|
|
49
|
-
background-color: ${({ color = "inherit" }) => color};
|
|
44
|
+
background-color: ${({ $color = "inherit" }) => $color};
|
|
50
45
|
border-bottom: unset;
|
|
51
46
|
color: inherit;
|
|
52
47
|
}
|
|
53
48
|
`;
|
|
54
49
|
|
|
55
50
|
function createHighlightColorAnnotation(options?: ColorAnnotationOptions) {
|
|
56
|
-
const
|
|
57
|
-
const renderAnnotation = options?.renderAnnotation;
|
|
51
|
+
const renderValue = options?.renderValue;
|
|
58
52
|
|
|
59
53
|
return defineField({
|
|
60
54
|
type: "object",
|
|
@@ -64,9 +58,10 @@ function createHighlightColorAnnotation(options?: ColorAnnotationOptions) {
|
|
|
64
58
|
fields: [defineField({ name: "color", type: "wild.color" })],
|
|
65
59
|
components: {
|
|
66
60
|
annotation: (props) => {
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
|
|
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>;
|
|
70
65
|
},
|
|
71
66
|
},
|
|
72
67
|
});
|
package/src/parts/spans/icon.tsx
CHANGED
|
@@ -3,19 +3,20 @@ 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
|
-
function defaultRenderIconPreview(value?:
|
|
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
|
|
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
|
|
19
|
+
const renderValue = options?.renderValue;
|
|
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:
|
|
41
|
+
media: renderValue?.(icon) ?? defaultRenderIconPreview(icon),
|
|
41
42
|
};
|
|
42
43
|
},
|
|
43
44
|
},
|