sanity-plugin-markdown 5.1.3 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # sanity-plugin-markdown
2
2
 
3
- > For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity-plugin-markdown/tree/studio-v2).
4
-
5
3
  ## What is it?
6
4
 
7
5
  A Markdown editor with preview for Sanity Studio.
@@ -190,18 +188,3 @@ defineField({
190
188
  ## License
191
189
 
192
190
  MIT-licensed. See LICENSE.
193
-
194
- ## Develop & test
195
-
196
- This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
197
- with default configuration for build & watch scripts.
198
-
199
- See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
200
- on how to run this plugin with hotreload in the studio.
201
-
202
- ### Release new version
203
-
204
- Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-markdown/actions/workflows/main.yml).
205
- Make sure to select the main branch and check "Release new version".
206
-
207
- Semantic release will only release on configured branches, so it is safe to run release on any branch.
@@ -0,0 +1,162 @@
1
+ import * as sanity0 from "sanity";
2
+ import { StringDefinition, StringInputProps } from "sanity";
3
+ import { SimpleMDEReactProps } from "react-simplemde-editor";
4
+ import { Options } from "easymde";
5
+ /**
6
+ * Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
7
+ * @internal
8
+ */
9
+ declare type Any = any;
10
+ /** @internal */
11
+ declare interface SanityAssetDocument extends SanityDocument {
12
+ url: string;
13
+ path: string;
14
+ size: number;
15
+ assetId: string;
16
+ mimeType: string;
17
+ sha1hash: string;
18
+ extension: string;
19
+ uploadId?: string;
20
+ originalFilename?: string;
21
+ }
22
+ /** @internal */
23
+ declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = { [P in keyof T]: T[P] } & {
24
+ _id: string;
25
+ _rev: string;
26
+ _type: string;
27
+ _createdAt: string;
28
+ _updatedAt: string;
29
+ /**
30
+ * Present when `perspective` is set to `previewDrafts`
31
+ */
32
+ _originalId?: string;
33
+ };
34
+ /** @internal */
35
+ declare interface SanityImageAssetDocument extends SanityAssetDocument {
36
+ metadata: {
37
+ _type: 'sanity.imageMetadata';
38
+ hasAlpha: boolean;
39
+ isOpaque: boolean;
40
+ lqip?: string;
41
+ blurHash?: string;
42
+ dimensions: {
43
+ _type: 'sanity.imageDimensions';
44
+ aspectRatio: number;
45
+ height: number;
46
+ width: number;
47
+ };
48
+ palette?: {
49
+ _type: 'sanity.imagePalette';
50
+ darkMuted?: SanityImagePalette;
51
+ darkVibrant?: SanityImagePalette;
52
+ dominant?: SanityImagePalette;
53
+ lightMuted?: SanityImagePalette;
54
+ lightVibrant?: SanityImagePalette;
55
+ muted?: SanityImagePalette;
56
+ vibrant?: SanityImagePalette;
57
+ };
58
+ image?: {
59
+ _type: 'sanity.imageExifTags';
60
+ [key: string]: Any;
61
+ };
62
+ exif?: {
63
+ _type: 'sanity.imageExifMetadata';
64
+ [key: string]: Any;
65
+ };
66
+ };
67
+ }
68
+ /** @internal */
69
+ declare interface SanityImagePalette {
70
+ background: string;
71
+ foreground: string;
72
+ population: number;
73
+ title: string;
74
+ }
75
+ declare const markdownTypeName: "markdown";
76
+ interface MarkdownOptions {
77
+ /**
78
+ * Used to create image url for any uploaded image.
79
+ * The function will be invoked whenever an image is pasted or dragged into the
80
+ * markdown editor, after upload completes.
81
+ *
82
+ * The default implementation uses
83
+ * ```js
84
+ * imageAsset => `${imageAsset.url}?w=450`
85
+ * ```
86
+ * ## Example
87
+ * ```js
88
+ * {
89
+ * imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`
90
+ * }
91
+ * ```
92
+ * @param imageAsset
93
+ */
94
+ imageUrl?: (imageAsset: SanityImageAssetDocument) => string;
95
+ }
96
+ /**
97
+ * @public
98
+ */
99
+ interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {
100
+ type: typeof markdownTypeName;
101
+ options?: MarkdownOptions;
102
+ }
103
+ declare module 'sanity' {
104
+ interface IntrinsicDefinitions {
105
+ markdown: MarkdownDefinition;
106
+ }
107
+ }
108
+ declare const markdownSchemaType: {
109
+ type: "string";
110
+ name: "markdown";
111
+ } & Omit<StringDefinition, "preview">;
112
+ interface MarkdownInputProps extends StringInputProps {
113
+ /**
114
+ * These are passed along directly to
115
+ *
116
+ * Note: MarkdownInput sets certain reactMdeProps.options by default.
117
+ * These will be merged with any custom options.
118
+ */
119
+ reactMdeProps?: Omit<SimpleMDEReactProps, 'value' | 'onChange'>;
120
+ }
121
+ declare const defaultMdeTools: Options['toolbar'];
122
+ declare function MarkdownInput(props: MarkdownInputProps): React.JSX.Element;
123
+ interface MarkdownConfig {
124
+ /**
125
+ * When provided, will replace the default input component.
126
+ *
127
+ * Use this to customize MarkdownInput by wrapping it in a custom component,
128
+ * and provide any custom props for https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
129
+ * via the `reactMdeProps` prop.
130
+ *
131
+ * ### Example
132
+ *
133
+ * ```tsx
134
+ * // CustomMarkdownInput.tsx
135
+ * import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'
136
+ *
137
+ * export function CustomMarkdownInput(props) {
138
+ * const reactMdeProps: MarkdownInputProps['reactMdeProps'] =
139
+ * useMemo(() => {
140
+ * return {
141
+ * options: {
142
+ * toolbar: ['bold', 'italic'],
143
+ * // more options available, see:
144
+ * // https://github.com/Ionaru/easy-markdown-editor#options-list
145
+ * },
146
+ * // more props available, see:
147
+ * // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
148
+ * }
149
+ * }, [])
150
+ *
151
+ * return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />
152
+ * }
153
+ *
154
+ * // studio.config.ts
155
+ * markdownSchema({input: CustomMarkdownInput})
156
+ * ```
157
+ */
158
+ input?: (props: StringInputProps) => React.ReactElement;
159
+ }
160
+ declare const markdownSchema: sanity0.Plugin<void | MarkdownConfig>;
161
+ export { defaultMdeTools as a, MarkdownInputProps as i, markdownSchema as n, MarkdownDefinition as o, MarkdownInput as r, markdownSchemaType as s, MarkdownConfig as t };
162
+ //# sourceMappingURL=commonExports.d.ts.map