@madebywild/sanity-richtext-field 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/blocks/index.d.ts +11 -0
- package/dist/blocks/index.js +5 -0
- package/dist/blocks/media-block.d.ts +11 -0
- package/dist/blocks/media-block.js +42 -0
- package/dist/fields.d.ts +34 -0
- package/dist/fields.js +112 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +122 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +52 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.js +2 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @madebywild/sanity-richtext-field
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const blocks: ({
|
|
2
|
+
type: "object";
|
|
3
|
+
name?: "wild.richtext.blocks.mediaBlock" | undefined;
|
|
4
|
+
} & Omit<import("sanity").ArrayOfEntry<import("sanity").ObjectDefinition>, "preview"> & {
|
|
5
|
+
preview?: import("sanity").PreviewConfig<{
|
|
6
|
+
type: string;
|
|
7
|
+
image: string;
|
|
8
|
+
playbackId: string;
|
|
9
|
+
thumbTime: string;
|
|
10
|
+
}, Record<"image" | "type" | "playbackId" | "thumbTime", any>> | undefined;
|
|
11
|
+
} & import("sanity").WidenValidation & import("sanity").WidenInitialValue)[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const mediaBlock: {
|
|
2
|
+
type: "object";
|
|
3
|
+
name?: "wild.richtext.blocks.mediaBlock" | undefined;
|
|
4
|
+
} & Omit<import("sanity").ArrayOfEntry<import("sanity").ObjectDefinition>, "preview"> & {
|
|
5
|
+
preview?: import("sanity").PreviewConfig<{
|
|
6
|
+
type: string;
|
|
7
|
+
image: string;
|
|
8
|
+
playbackId: string;
|
|
9
|
+
thumbTime: string;
|
|
10
|
+
}, Record<"image" | "type" | "playbackId" | "thumbTime", any>> | undefined;
|
|
11
|
+
} & import("sanity").WidenValidation & import("sanity").WidenInitialValue;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { buildMediaPreview } from "@madebywild/sanity-media-field";
|
|
3
|
+
import { defineArrayMember, defineField } from "sanity";
|
|
4
|
+
export const mediaBlock = defineArrayMember({
|
|
5
|
+
name: "wild.richtext.blocks.mediaBlock",
|
|
6
|
+
type: "object",
|
|
7
|
+
title: "Media Block",
|
|
8
|
+
description: "Embed block video or image content.",
|
|
9
|
+
icon: () => _jsx(_Fragment, { children: "\uD83D\uDDBC\uFE0F" }),
|
|
10
|
+
fields: [
|
|
11
|
+
defineField({
|
|
12
|
+
title: "Wrap",
|
|
13
|
+
name: "wrapping",
|
|
14
|
+
type: "wild.wrapping",
|
|
15
|
+
}),
|
|
16
|
+
defineField({
|
|
17
|
+
name: "appMedia",
|
|
18
|
+
type: "wild.media",
|
|
19
|
+
options: {
|
|
20
|
+
withCustomRatio: true,
|
|
21
|
+
withCustomOptions: true,
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
defineField({
|
|
25
|
+
name: "caption",
|
|
26
|
+
type: "text",
|
|
27
|
+
rows: 2,
|
|
28
|
+
description: "Add a caption for the media.",
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
preview: {
|
|
32
|
+
select: {
|
|
33
|
+
type: "appMedia.type",
|
|
34
|
+
image: "appMedia.image",
|
|
35
|
+
playbackId: "appMedia.video.asset.playbackId",
|
|
36
|
+
thumbTime: "appMedia.video.asset.thumbTime",
|
|
37
|
+
},
|
|
38
|
+
prepare: (props) => {
|
|
39
|
+
return buildMediaPreview(props);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const linkField: {
|
|
2
|
+
type: "wild.link";
|
|
3
|
+
name: "linkField";
|
|
4
|
+
} & import("sanity").TypeAliasDefinition<"wild.link", "string" | "number" | "boolean" | "object" | "wild.media" | "wild.richtext.basic" | "wild.richtext.extended" | "array" | "block" | "date" | "datetime" | "document" | "file" | "geopoint" | "image" | "reference" | "crossDatasetReference" | "globalDocumentReference" | "slug" | "text" | "url" | "email" | undefined> & {
|
|
5
|
+
preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
6
|
+
} & import("sanity").FieldDefinitionBase & import("sanity").WidenValidation & import("sanity").WidenInitialValue;
|
|
7
|
+
export declare const textColorField: {
|
|
8
|
+
type: "object";
|
|
9
|
+
name: "textColorField";
|
|
10
|
+
} & Omit<import("sanity").ObjectDefinition, "preview"> & {
|
|
11
|
+
preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
12
|
+
} & import("sanity").FieldDefinitionBase & import("sanity").WidenValidation & import("sanity").WidenInitialValue;
|
|
13
|
+
export declare const highlightColorField: {
|
|
14
|
+
type: "object";
|
|
15
|
+
name: "highlightColorField";
|
|
16
|
+
} & Omit<import("sanity").ObjectDefinition, "preview"> & {
|
|
17
|
+
preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
18
|
+
} & import("sanity").FieldDefinitionBase & import("sanity").WidenValidation & import("sanity").WidenInitialValue;
|
|
19
|
+
export declare const appIconField: {
|
|
20
|
+
type: "object";
|
|
21
|
+
name?: "appIconField" | undefined;
|
|
22
|
+
} & Omit<import("sanity").ArrayOfEntry<import("sanity").ObjectDefinition>, "preview"> & {
|
|
23
|
+
preview?: import("sanity").PreviewConfig<{
|
|
24
|
+
icon: string;
|
|
25
|
+
}, Record<"icon", any>> | undefined;
|
|
26
|
+
} & import("sanity").WidenValidation & import("sanity").WidenInitialValue;
|
|
27
|
+
export declare const inlineMediaField: {
|
|
28
|
+
type: "object";
|
|
29
|
+
name?: "inlineMediaField" | undefined;
|
|
30
|
+
} & Omit<import("sanity").ArrayOfEntry<import("sanity").ObjectDefinition>, "preview"> & {
|
|
31
|
+
preview?: import("sanity").PreviewConfig<{
|
|
32
|
+
type: string;
|
|
33
|
+
}, Record<"type", any>> | undefined;
|
|
34
|
+
} & import("sanity").WidenValidation & import("sanity").WidenInitialValue;
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { LinkIcon } from "@sanity/icons";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { defineArrayMember, defineField } from "sanity";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
export const linkField = defineField({
|
|
7
|
+
type: "wild.link",
|
|
8
|
+
name: "linkField",
|
|
9
|
+
title: "Link",
|
|
10
|
+
icon: LinkIcon,
|
|
11
|
+
options: {
|
|
12
|
+
noCustomText: true,
|
|
13
|
+
collapsed: false,
|
|
14
|
+
collapsible: false,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const ColorText = styled.span `
|
|
18
|
+
& > span {
|
|
19
|
+
background-color: inherit;
|
|
20
|
+
border-bottom: unset;
|
|
21
|
+
color: ${({ color = "inherit" }) => color};
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
export const textColorField = defineField({
|
|
25
|
+
type: "object",
|
|
26
|
+
name: "textColorField",
|
|
27
|
+
title: "Text Color",
|
|
28
|
+
icon: () => _jsx(_Fragment, { children: "\uD83D\uDD8B" }),
|
|
29
|
+
fields: [defineField({ name: "color", type: "wild.color" })],
|
|
30
|
+
components: {
|
|
31
|
+
annotation: (props) => {
|
|
32
|
+
const color = props.value?.color;
|
|
33
|
+
return _jsx(ColorText, { color: color, children: props.renderDefault(props) });
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const ColorBg = styled.span `
|
|
38
|
+
& > span {
|
|
39
|
+
background-color: ${({ color = "inherit" }) => color};
|
|
40
|
+
border-bottom: unset;
|
|
41
|
+
color: inherit;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export const highlightColorField = defineField({
|
|
45
|
+
type: "object",
|
|
46
|
+
name: "highlightColorField",
|
|
47
|
+
title: "Highlight Color",
|
|
48
|
+
icon: () => _jsx(_Fragment, { children: "\uD83D\uDD8D" }),
|
|
49
|
+
fields: [defineField({ name: "color", type: "wild.color" })],
|
|
50
|
+
components: {
|
|
51
|
+
annotation: (props) => {
|
|
52
|
+
const color = props.value?.color;
|
|
53
|
+
return _jsx(ColorBg, { color: color, children: props.renderDefault(props) });
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
export const appIconField = defineArrayMember({
|
|
58
|
+
name: "appIconField",
|
|
59
|
+
type: "object",
|
|
60
|
+
title: "Icon",
|
|
61
|
+
description: "Insert an icon.",
|
|
62
|
+
icon: () => _jsx(_Fragment, { children: "\uD83E\uDDFF" }),
|
|
63
|
+
fields: [defineField({ name: "icon", type: "wild.icon" })],
|
|
64
|
+
components: {
|
|
65
|
+
// This is the inline-preview in the PortableText editor.
|
|
66
|
+
// It gets its props from the prepare function below.
|
|
67
|
+
preview: (props) => {
|
|
68
|
+
return React.isValidElement(props.media) ? props.media : props.fallbackTitle;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
preview: {
|
|
72
|
+
select: {
|
|
73
|
+
icon: "icon",
|
|
74
|
+
},
|
|
75
|
+
prepare({ icon }) {
|
|
76
|
+
return {
|
|
77
|
+
media: (_jsx("span", { role: "img", className: "inline-block size-[1em] shrink-0 text-current", title: icon ?? "Icon", children: "\uD83E\uDDFF" })),
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
export const inlineMediaField = defineArrayMember({
|
|
83
|
+
name: "inlineMediaField",
|
|
84
|
+
type: "object",
|
|
85
|
+
title: "Inline Media",
|
|
86
|
+
description: "Embed inline video or image content.",
|
|
87
|
+
icon: () => _jsx(_Fragment, { children: "\uD83E\uDEE7" }),
|
|
88
|
+
fields: [
|
|
89
|
+
defineField({
|
|
90
|
+
name: "media",
|
|
91
|
+
type: "wild.media",
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
components: {
|
|
95
|
+
// This is the inline-preview in the PortableText editor.
|
|
96
|
+
preview: (props) => {
|
|
97
|
+
const icons = {
|
|
98
|
+
video: _jsx(_Fragment, { children: "\uD83C\uDFA5" }),
|
|
99
|
+
image: _jsx(_Fragment, { children: "\uD83D\uDDBC\uFE0F" }),
|
|
100
|
+
lottie: _jsx(_Fragment, { children: "\uD83C\uDF00" }),
|
|
101
|
+
rive: _jsx(_Fragment, { children: "\uD83C\uDF6D" }),
|
|
102
|
+
};
|
|
103
|
+
// @ts-expect-error: It gets its props from the prepare function below.
|
|
104
|
+
return icons[props.type] || _jsx(_Fragment, { children: "\uD83D\uDDBC\uFE0F" });
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
preview: {
|
|
108
|
+
select: {
|
|
109
|
+
type: "media.type",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { defineArrayMember, definePlugin, defineType } from "sanity";
|
|
3
|
+
import { blocks } from "./blocks";
|
|
4
|
+
import { appIconField, highlightColorField, inlineMediaField, linkField, textColorField } from "./fields";
|
|
5
|
+
import { typeNameBasic, typeNameExtended } from "./types";
|
|
6
|
+
function StudioLayout(props) {
|
|
7
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", {
|
|
8
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: we control the source.
|
|
9
|
+
dangerouslySetInnerHTML: {
|
|
10
|
+
__html: `
|
|
11
|
+
fieldset [data-testid="pt-editor"][data-fullscreen="false"] {
|
|
12
|
+
height: var(--pt-editor-height, initial);
|
|
13
|
+
}
|
|
14
|
+
`,
|
|
15
|
+
} }), props.renderDefault(props)] }));
|
|
16
|
+
}
|
|
17
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: it can be void.
|
|
18
|
+
const wildSanityRichtextFieldPlugin = definePlugin((config) => {
|
|
19
|
+
const userBlocks = config?.blocks ?? [];
|
|
20
|
+
const userSpans = config?.spans ?? [];
|
|
21
|
+
const userDecorators = config?.decorators ?? [];
|
|
22
|
+
const userAnnotations = config?.annotations ?? [];
|
|
23
|
+
const userLists = config?.lists ?? [];
|
|
24
|
+
const userStyles = config?.styles ?? [];
|
|
25
|
+
return {
|
|
26
|
+
name: "@madebywild/sanity-richtext-field",
|
|
27
|
+
studio: {
|
|
28
|
+
components: {
|
|
29
|
+
layout: StudioLayout,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
schema: {
|
|
33
|
+
types: [
|
|
34
|
+
defineType({
|
|
35
|
+
name: typeNameBasic,
|
|
36
|
+
type: "array",
|
|
37
|
+
title: "Rich Text",
|
|
38
|
+
description: "Rich text content with formatting options.",
|
|
39
|
+
icon: () => _jsx(_Fragment, { children: "\u2328\uFE0F" }),
|
|
40
|
+
components: {
|
|
41
|
+
// biome-ignore lint/suspicious/noExplicitAny: Sanity doesn't provide these types.
|
|
42
|
+
field: (props) => {
|
|
43
|
+
return (
|
|
44
|
+
// The CSS variable is used the set the min-height of the Portable Text editor.
|
|
45
|
+
_jsx("div", { style: { "--pt-editor-height": "10rem" }, children: props.renderDefault({ ...props, initialActive: true }) }));
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
of: [
|
|
49
|
+
defineArrayMember({
|
|
50
|
+
type: "block",
|
|
51
|
+
options: {
|
|
52
|
+
spellCheck: false,
|
|
53
|
+
unstable_whitespaceOnPasteMode: "normalize",
|
|
54
|
+
},
|
|
55
|
+
of: [appIconField, inlineMediaField],
|
|
56
|
+
styles: [],
|
|
57
|
+
lists: [],
|
|
58
|
+
marks: {
|
|
59
|
+
annotations: [linkField],
|
|
60
|
+
decorators: [
|
|
61
|
+
{ title: "Strong", value: "strong" },
|
|
62
|
+
{ title: "Emphasis", value: "em" },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
}),
|
|
68
|
+
defineType({
|
|
69
|
+
name: typeNameExtended,
|
|
70
|
+
type: "array",
|
|
71
|
+
title: "Rich Text",
|
|
72
|
+
description: "Rich text content with formatting options.",
|
|
73
|
+
icon: () => _jsx(_Fragment, { children: "\u2328\uFE0F" }),
|
|
74
|
+
components: {
|
|
75
|
+
// biome-ignore lint/suspicious/noExplicitAny: Sanity doesn't provide these types.
|
|
76
|
+
field: (props) => {
|
|
77
|
+
return (
|
|
78
|
+
// The CSS variable is used the set the min-height of the Portable Text editor.
|
|
79
|
+
_jsx("div", { style: { "--pt-editor-height": "50vh" }, children: props.renderDefault({ ...props, initialActive: true }) }));
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
of: [
|
|
83
|
+
...userBlocks,
|
|
84
|
+
...blocks,
|
|
85
|
+
defineArrayMember({
|
|
86
|
+
type: "block",
|
|
87
|
+
options: {
|
|
88
|
+
spellCheck: config?.spellCheck ?? true,
|
|
89
|
+
unstable_whitespaceOnPasteMode: "normalize",
|
|
90
|
+
},
|
|
91
|
+
of: [...userSpans, appIconField, inlineMediaField],
|
|
92
|
+
styles: [
|
|
93
|
+
...userStyles,
|
|
94
|
+
{ title: "Normal", value: "normal" },
|
|
95
|
+
{ title: "Heading 2", value: "h2" },
|
|
96
|
+
{ title: "Heading 3", value: "h3" },
|
|
97
|
+
{ title: "Heading 4", value: "h4" },
|
|
98
|
+
],
|
|
99
|
+
lists: [...userLists, { title: "Bullet", value: "bullet" }, { title: "Number", value: "number" }],
|
|
100
|
+
marks: {
|
|
101
|
+
annotations: [...userAnnotations, linkField, textColorField, highlightColorField],
|
|
102
|
+
decorators: [
|
|
103
|
+
...userDecorators,
|
|
104
|
+
{ title: "Strong", value: "strong" },
|
|
105
|
+
{ title: "Emphasis", value: "em" },
|
|
106
|
+
{ title: "Code", value: "code" },
|
|
107
|
+
{
|
|
108
|
+
title: "Sup",
|
|
109
|
+
value: "sup",
|
|
110
|
+
icon: () => _jsx("sup", { children: "[1]" }),
|
|
111
|
+
component: (props) => _jsx("sup", { style: { verticalAlign: "super" }, children: props.children }),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
],
|
|
117
|
+
}),
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
export { wildSanityRichtextFieldPlugin, typeNameBasic, typeNameExtended };
|
package/dist/input.d.ts
ADDED
package/dist/input.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Card, Flex, Stack, Text } from "@sanity/ui";
|
|
3
|
+
import { AsyncAutocomplete } from "@wild-sanity-kit/utils";
|
|
4
|
+
import * as changeCase from "change-case";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { MemberField, set, unset, useClient } from "sanity";
|
|
7
|
+
function useFieldMember(members, fieldName) {
|
|
8
|
+
return React.useMemo(() => members.find((member) => member.kind === "field" && member.name === fieldName), [members, fieldName]);
|
|
9
|
+
}
|
|
10
|
+
function InternalLinkInput({ config, value, onChange, }) {
|
|
11
|
+
const linkQuery = config.internalLinkQuery;
|
|
12
|
+
const queryTransformer = config.internalLinkTransformer;
|
|
13
|
+
const client = useClient({ apiVersion: "2025-10-21" });
|
|
14
|
+
const [items, setItems] = React.useState([]);
|
|
15
|
+
const selectedItem = items.find((_) => _.value === value?.link?._ref);
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
client
|
|
18
|
+
.fetch(linkQuery)
|
|
19
|
+
.then(queryTransformer)
|
|
20
|
+
.then((items) => items.sort((a, b) => a.label.localeCompare(b.label)))
|
|
21
|
+
.then(setItems);
|
|
22
|
+
}, [client, linkQuery, queryTransformer]);
|
|
23
|
+
return (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsx(AsyncAutocomplete, { placeholder: "Select page", defaultValue: value?.link?._ref, listItems: items, onChange: (value) => {
|
|
24
|
+
const next = value ? set({ _ref: value, _type: "reference" }, ["link"]) : unset(["link"]);
|
|
25
|
+
return onChange(next);
|
|
26
|
+
}, renderValue: (value, opt) => {
|
|
27
|
+
return opt?.label ? changeCase.capitalCase(opt.label) : value;
|
|
28
|
+
}, renderOption: ({ label, uri }) => {
|
|
29
|
+
return (_jsx(Card, { as: "button", children: _jsxs(Flex, { flex: 1, padding: 3, gap: 2, direction: "column", children: [_jsx(Text, { size: 2, children: changeCase.capitalCase(label) }), _jsx(Text, { size: 0, muted: true, children: uri })] }) }));
|
|
30
|
+
} }), selectedItem?.sections?.length ? (_jsx(AsyncAutocomplete, { placeholder: "Select section", defaultValue: value?.sectionTarget, listItems: selectedItem?.sections, onChange: (value) => {
|
|
31
|
+
const next = value ? set(value, ["sectionTarget"]) : unset(["sectionTarget"]);
|
|
32
|
+
return onChange(next);
|
|
33
|
+
}, renderValue: (value, opt) => {
|
|
34
|
+
return opt?.label ? changeCase.capitalCase(opt.label) : value;
|
|
35
|
+
}, renderOption: ({ label }) => {
|
|
36
|
+
return (_jsx(Card, { as: "button", children: _jsx(Box, { flex: 1, padding: 3, children: _jsx(Text, { size: 2, children: changeCase.capitalCase(label) }) }) }));
|
|
37
|
+
} })) : null] }));
|
|
38
|
+
}
|
|
39
|
+
function LinkInput(props) {
|
|
40
|
+
const options = props.schemaType.options;
|
|
41
|
+
const typeFieldMember = useFieldMember(props.members, "type");
|
|
42
|
+
const externalFieldMember = useFieldMember(props.members, "external");
|
|
43
|
+
const emailFieldMember = useFieldMember(props.members, "email");
|
|
44
|
+
const phoneFieldMember = useFieldMember(props.members, "phone");
|
|
45
|
+
const fileFieldMember = useFieldMember(props.members, "file");
|
|
46
|
+
const canDownloadFieldMember = useFieldMember(props.members, "canDownload");
|
|
47
|
+
const internalFieldMember = useFieldMember(props.members, "internal");
|
|
48
|
+
const customTextFieldMember = useFieldMember(props.members, "customText");
|
|
49
|
+
const openInNewTabFieldMember = useFieldMember(props.members, "openInNewTab");
|
|
50
|
+
return (_jsxs(Stack, { space: 4, children: [typeFieldMember && _jsx(MemberField, { member: typeFieldMember, ...props }), externalFieldMember && _jsx(MemberField, { member: externalFieldMember, ...props }), emailFieldMember && _jsx(MemberField, { member: emailFieldMember, ...props }), phoneFieldMember && _jsx(MemberField, { member: phoneFieldMember, ...props }), fileFieldMember && _jsx(MemberField, { member: fileFieldMember, ...props }), canDownloadFieldMember && _jsx(MemberField, { member: canDownloadFieldMember, ...props }), internalFieldMember && _jsx(InternalLinkInput, { ...props }), !options?.noCustomText && customTextFieldMember && _jsx(MemberField, { member: customTextFieldMember, ...props }), openInNewTabFieldMember && _jsx(MemberField, { member: openInNewTabFieldMember, ...props })] }));
|
|
51
|
+
}
|
|
52
|
+
export { LinkInput };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ArrayDefinition, ArrayOfType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition } from "sanity";
|
|
2
|
+
export declare const typeNameBasic: "wild.richtext.basic";
|
|
3
|
+
export declare const typeNameExtended: "wild.richtext.extended";
|
|
4
|
+
export type PluginConfig = {
|
|
5
|
+
spellCheck?: boolean;
|
|
6
|
+
blocks?: ArrayOfType<"object">[];
|
|
7
|
+
spans?: ArrayOfType<"object">[];
|
|
8
|
+
styles?: BlockStyleDefinition[];
|
|
9
|
+
lists?: BlockListDefinition[];
|
|
10
|
+
annotations?: ArrayOfType<"object">[];
|
|
11
|
+
decorators?: BlockDecoratorDefinition[];
|
|
12
|
+
};
|
|
13
|
+
declare module "sanity" {
|
|
14
|
+
interface IntrinsicDefinitions {
|
|
15
|
+
[typeNameBasic]: Omit<ArrayDefinition, "type" | "of"> & {
|
|
16
|
+
type: typeof typeNameBasic;
|
|
17
|
+
};
|
|
18
|
+
[typeNameExtended]: Omit<ArrayDefinition, "type" | "of"> & {
|
|
19
|
+
type: typeof typeNameExtended;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@madebywild/sanity-richtext-field",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"clear": "rm -rf dist",
|
|
16
|
+
"typecheck": "tsc --noEmit"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@madebywild/sanity-media-field": "*",
|
|
20
|
+
"@madebywild/sanity-utils": "*"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"sanity": "^4.17",
|
|
24
|
+
"react": "^19",
|
|
25
|
+
"react-dom": "^19"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"sanity": "^4.17",
|
|
29
|
+
"react": "^19",
|
|
30
|
+
"react-dom": "^19",
|
|
31
|
+
"typescript": "^5.9",
|
|
32
|
+
"@types/react": "^19",
|
|
33
|
+
"@types/react-dom": "^19"
|
|
34
|
+
}
|
|
35
|
+
}
|