@driftime/sanity-plugin-handbook 0.3.2 → 0.4.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 +302 -167
- package/dist/index.d.ts +99 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1725 -1679
- package/dist/index.js.map +1 -1
- package/package.json +17 -28
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,229 +1,232 @@
|
|
|
1
|
-
import { CurrentUser, DocumentDefinition, KeyedSegment, PortableTextBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock, SanityDocument, SchemaTypeDefinition } from "sanity";
|
|
2
1
|
import { ComponentType } from "react";
|
|
3
|
-
import "
|
|
2
|
+
import { CurrentUser, DocumentDefinition, KeyedSegment, PortableTextBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock, SanityDocument, SchemaTypeDefinition } from "sanity";
|
|
4
3
|
import { StructureBuilder } from "sanity/structure";
|
|
5
4
|
declare module "@sanity/types" {
|
|
6
5
|
interface FieldDefinitionBase {
|
|
6
|
+
/** Handbook documentation for the field. */
|
|
7
7
|
handbook?: SanityHandbookMetadata;
|
|
8
8
|
}
|
|
9
9
|
interface DocumentDefinition {
|
|
10
|
+
/** Handbook documentation for the document type. */
|
|
10
11
|
handbook?: SanityHandbookMetadata;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* Documentation
|
|
15
|
+
* Documentation added to a field or document definition, shown in the Handbook.
|
|
15
16
|
*
|
|
16
17
|
* @public
|
|
17
18
|
*/
|
|
18
19
|
interface SanityHandbookMetadata {
|
|
19
|
-
/**
|
|
20
|
+
/** Title to show instead of the schema title. */
|
|
20
21
|
title?: string;
|
|
21
|
-
/** Description shown
|
|
22
|
+
/** Description shown below the field or document heading. */
|
|
22
23
|
description?: string;
|
|
23
|
-
/**
|
|
24
|
+
/** Example value for the field. */
|
|
24
25
|
example?: string;
|
|
25
|
-
/**
|
|
26
|
+
/** Tip, shown as a hint icon. */
|
|
26
27
|
tip?: string;
|
|
27
|
-
/**
|
|
28
|
+
/** Extra information, shown as a hint icon. */
|
|
28
29
|
info?: string;
|
|
29
|
-
/** Warning
|
|
30
|
+
/** Warning, shown as a hint icon. */
|
|
30
31
|
caution?: string;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
|
-
* A
|
|
34
|
+
* A group of document types with the same role in the content model, shown as one sidebar section.
|
|
34
35
|
*
|
|
35
36
|
* @public
|
|
36
37
|
*/
|
|
37
38
|
interface SanityHandbookDocumentRole {
|
|
38
|
-
/**
|
|
39
|
+
/** Role title. */
|
|
39
40
|
title: string;
|
|
40
|
-
/**
|
|
41
|
+
/** Short description of the role. */
|
|
41
42
|
description?: string;
|
|
42
|
-
/** Document definitions
|
|
43
|
+
/** Document definitions in the role. */
|
|
43
44
|
documents: DocumentDefinition[];
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
|
-
* A Portable Text block
|
|
47
|
+
* A custom Portable Text block for guides: its schema and the component that renders it.
|
|
47
48
|
*
|
|
48
49
|
* @public
|
|
49
50
|
*/
|
|
50
51
|
interface SanityHandbookBlockDefinition {
|
|
51
|
-
/**
|
|
52
|
+
/** Schema type definition for the block. */
|
|
52
53
|
schema: SchemaTypeDefinition;
|
|
53
|
-
/**
|
|
54
|
+
/** Component that renders the block in the Handbook. */
|
|
54
55
|
component: ComponentType<{
|
|
55
56
|
value: PortableTextObject;
|
|
56
57
|
}>;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
|
-
*
|
|
60
|
+
* Plugin configuration. Only `roles` is required.
|
|
60
61
|
*
|
|
61
62
|
* @public
|
|
62
63
|
*/
|
|
63
64
|
interface SanityHandbookConfig {
|
|
64
|
-
/** Title
|
|
65
|
+
/** Title in the Studio's tool menu. Defaults to `"Handbook"`. */
|
|
65
66
|
title?: string;
|
|
66
|
-
/** Heading
|
|
67
|
+
/** Heading at the top of the sidebar. Defaults to `"Handbook"`. */
|
|
67
68
|
sidebarTitle?: string;
|
|
68
|
-
/** Document roles, each shown as a
|
|
69
|
+
/** Document roles, each shown as a section in the sidebar. */
|
|
69
70
|
roles: SanityHandbookDocumentRole[];
|
|
70
|
-
/** Custom Portable Text
|
|
71
|
+
/** Custom Portable Text blocks for guides. Defaults to none. */
|
|
71
72
|
blocks?: SanityHandbookBlockDefinition[];
|
|
72
|
-
/** Email addresses
|
|
73
|
+
/** Email addresses of the people who can edit Handbook documents. Defaults to everyone. */
|
|
73
74
|
editors?: string[];
|
|
74
|
-
/**
|
|
75
|
+
/** Message shown for fields without a description. Defaults to a prompt to ask the development team. */
|
|
75
76
|
undocumentedFieldMessage?: string;
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
79
|
+
* Adds a Handbook tool to Sanity Studio, with documentation generated from the schema and guides written
|
|
80
|
+
* in the Studio.
|
|
80
81
|
*
|
|
81
|
-
* @param config -
|
|
82
|
-
* @returns
|
|
82
|
+
* @param config - The plugin configuration.
|
|
83
|
+
* @returns The plugin.
|
|
83
84
|
* @public
|
|
84
85
|
*/
|
|
85
86
|
export declare const handbookPlugin: import("sanity").Plugin<SanityHandbookConfig>;
|
|
86
87
|
/**
|
|
87
|
-
* Creates
|
|
88
|
-
* not permitted to edit them.
|
|
88
|
+
* Creates Structure tool items for the Handbook documents, or none when the current user can't edit them.
|
|
89
89
|
*
|
|
90
|
-
* @param structureBuilder - The
|
|
91
|
-
* @param context - The
|
|
92
|
-
* @param editors - Email addresses
|
|
93
|
-
* @returns
|
|
90
|
+
* @param structureBuilder - The structure builder.
|
|
91
|
+
* @param context - The structure context, with the current user.
|
|
92
|
+
* @param editors - Email addresses of the editors, defaulting to the configured list.
|
|
93
|
+
* @returns List items for the Handbook document and the guides list, oldest guide first.
|
|
94
94
|
* @public
|
|
95
95
|
*/
|
|
96
96
|
export declare function handbookStructure(structureBuilder: StructureBuilder, context: {
|
|
97
97
|
currentUser: CurrentUser | null;
|
|
98
98
|
}, editors?: string[]): import("sanity/structure").ListItemBuilder[];
|
|
99
99
|
/**
|
|
100
|
-
* Checks whether the current user
|
|
101
|
-
* unrestricted access.
|
|
100
|
+
* Checks whether the current user can edit Handbook documents. Without an editors list, everyone can.
|
|
102
101
|
*
|
|
103
|
-
* @param editors - Email addresses
|
|
102
|
+
* @param editors - Email addresses of the editors, defaulting to the configured list.
|
|
104
103
|
* @returns Whether the current user can edit Handbook documents.
|
|
105
104
|
* @public
|
|
106
105
|
*/
|
|
107
106
|
export declare function useIsHandbookEditor(editors?: string[]): boolean;
|
|
108
|
-
/**
|
|
107
|
+
/** Removes a type's index signatures, so a misspelt property is an error rather than `unknown`. */
|
|
109
108
|
type Strict<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
|
|
110
|
-
/** Array
|
|
109
|
+
/** Array whose items carry the `_key` Sanity gives array members. */
|
|
111
110
|
type SanityKeyedArray<T> = (KeyedSegment & T)[];
|
|
112
111
|
/**
|
|
113
|
-
* A
|
|
112
|
+
* A Handbook guide, written in rich text and shown in the tool.
|
|
114
113
|
*
|
|
115
114
|
* @public
|
|
116
115
|
*/
|
|
117
116
|
type SanityHandbookGuide = Strict<SanityDocument> & {
|
|
118
117
|
_type: typeof guideTypeName;
|
|
119
|
-
/**
|
|
118
|
+
/** Guide title. */
|
|
120
119
|
title: string;
|
|
121
|
-
/**
|
|
120
|
+
/** Short description below the guide heading. */
|
|
122
121
|
description?: string;
|
|
123
|
-
/** Portable Text content
|
|
122
|
+
/** Portable Text content. */
|
|
124
123
|
content: SanityKeyedArray<PortableTextBlock>;
|
|
125
124
|
};
|
|
126
|
-
/**
|
|
125
|
+
/** Schema type name of the guide document. */
|
|
127
126
|
declare const guideTypeName = "handbook.guide";
|
|
128
127
|
/**
|
|
129
|
-
* A
|
|
128
|
+
* A group of guides in the sidebar, in order.
|
|
130
129
|
*
|
|
131
130
|
* @public
|
|
132
131
|
*/
|
|
133
132
|
interface SanityHandbookGuideGroup {
|
|
134
|
-
/**
|
|
133
|
+
/** Group title in the sidebar. */
|
|
135
134
|
title: string;
|
|
136
|
-
/**
|
|
135
|
+
/** Guides in the group, in order. */
|
|
137
136
|
guides: SanityKeyedArray<SanityHandbookGuide>;
|
|
138
137
|
}
|
|
139
138
|
/**
|
|
140
|
-
* The
|
|
139
|
+
* The Handbook document, listing the guide groups in sidebar order.
|
|
141
140
|
*
|
|
142
141
|
* @public
|
|
143
142
|
*/
|
|
144
143
|
type SanityHandbook = Strict<SanityDocument> & {
|
|
145
144
|
_type: typeof handbookTypeName;
|
|
146
|
-
/**
|
|
145
|
+
/** Guide groups, in order. */
|
|
147
146
|
groups: SanityKeyedArray<SanityHandbookGuideGroup>;
|
|
148
147
|
};
|
|
149
|
-
/**
|
|
148
|
+
/** Schema type name of the Handbook document. */
|
|
150
149
|
declare const handbookTypeName = "handbook.handbook";
|
|
151
|
-
/** The intent a callout is drawn with, choosing its icon and tone. */
|
|
152
|
-
type CalloutVariant = "tip" | "info" | "warning";
|
|
153
150
|
/**
|
|
154
|
-
*
|
|
151
|
+
* An image in a guide, with its caption and alternative text.
|
|
155
152
|
*
|
|
156
153
|
* @public
|
|
157
154
|
*/
|
|
158
|
-
type
|
|
159
|
-
_type: typeof
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
type SanityHandbookImage = Strict<PortableTextObject> & {
|
|
156
|
+
_type: typeof imageTypeName;
|
|
157
|
+
/** Image asset, reduced by the query to its URL. */
|
|
158
|
+
asset?: {
|
|
159
|
+
url?: string;
|
|
160
|
+
};
|
|
161
|
+
/** Text shown below the image. */
|
|
162
|
+
caption?: string;
|
|
163
|
+
/** Alternative text. */
|
|
164
|
+
alt?: string;
|
|
164
165
|
};
|
|
165
|
-
/**
|
|
166
|
-
declare const
|
|
166
|
+
/** Schema type name of the image block. */
|
|
167
|
+
declare const imageTypeName = "handbook.image";
|
|
168
|
+
/**
|
|
169
|
+
* A video in a guide, with its caption.
|
|
170
|
+
*
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
type SanityHandbookVideo = Strict<PortableTextObject> & {
|
|
174
|
+
_type: typeof videoTypeName;
|
|
175
|
+
/** Video asset, reduced by the query to its URL. */
|
|
176
|
+
asset?: {
|
|
177
|
+
url?: string;
|
|
178
|
+
};
|
|
179
|
+
/** Text shown below the video. */
|
|
180
|
+
caption?: string;
|
|
181
|
+
};
|
|
182
|
+
/** Schema type name of the video block. */
|
|
183
|
+
declare const videoTypeName = "handbook.video";
|
|
167
184
|
/**
|
|
168
|
-
* A block
|
|
185
|
+
* A code block, highlighted for its language.
|
|
169
186
|
*
|
|
170
187
|
* @public
|
|
171
188
|
*/
|
|
172
189
|
type SanityHandbookCode = Strict<PortableTextObject> & {
|
|
173
190
|
_type: typeof codeTypeName;
|
|
174
|
-
/**
|
|
191
|
+
/** Code to display. */
|
|
175
192
|
code?: string;
|
|
176
|
-
/**
|
|
193
|
+
/** Language used for syntax highlighting. */
|
|
177
194
|
language?: string;
|
|
178
195
|
};
|
|
179
|
-
/**
|
|
196
|
+
/** Schema type name of the code block. */
|
|
180
197
|
declare const codeTypeName = "handbook.code";
|
|
181
198
|
/**
|
|
182
|
-
*
|
|
199
|
+
* Kind of callout, which sets its icon and tone.
|
|
183
200
|
*
|
|
184
201
|
* @public
|
|
185
202
|
*/
|
|
186
|
-
type
|
|
187
|
-
_type: typeof horizontalRuleTypeName;
|
|
188
|
-
};
|
|
189
|
-
/** Type name of the horizontal rule block. */
|
|
190
|
-
declare const horizontalRuleTypeName = "handbook.horizontalRule";
|
|
203
|
+
type SanityHandbookCalloutVariant = "tip" | "info" | "warning";
|
|
191
204
|
/**
|
|
192
|
-
*
|
|
205
|
+
* A highlighted message in a guide.
|
|
193
206
|
*
|
|
194
207
|
* @public
|
|
195
208
|
*/
|
|
196
|
-
type
|
|
197
|
-
_type: typeof
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
/** Text displayed beneath the image. */
|
|
203
|
-
caption?: string;
|
|
204
|
-
/** Alternative text for screen readers. */
|
|
205
|
-
alt?: string;
|
|
209
|
+
type SanityHandbookCallout = Strict<PortableTextObject> & {
|
|
210
|
+
_type: typeof calloutTypeName;
|
|
211
|
+
/** Kind of callout. */
|
|
212
|
+
variant: SanityHandbookCalloutVariant;
|
|
213
|
+
/** Portable Text inside the callout, without inline objects. */
|
|
214
|
+
body: SanityKeyedArray<PortableTextTextBlock<PortableTextSpan>>;
|
|
206
215
|
};
|
|
207
|
-
/**
|
|
208
|
-
declare const
|
|
216
|
+
/** Schema type name of the callout block. */
|
|
217
|
+
declare const calloutTypeName = "handbook.callout";
|
|
209
218
|
/**
|
|
210
|
-
* A
|
|
219
|
+
* A divider between sections of a guide.
|
|
211
220
|
*
|
|
212
221
|
* @public
|
|
213
222
|
*/
|
|
214
|
-
type
|
|
215
|
-
_type: typeof
|
|
216
|
-
/** Uploaded video asset, narrowed by the query to the URL the viewer renders. */
|
|
217
|
-
asset?: {
|
|
218
|
-
url?: string;
|
|
219
|
-
};
|
|
220
|
-
/** Text displayed beneath the video. */
|
|
221
|
-
caption?: string;
|
|
223
|
+
type SanityHandbookHorizontalRule = Strict<PortableTextObject> & {
|
|
224
|
+
_type: typeof horizontalRuleTypeName;
|
|
222
225
|
};
|
|
223
|
-
/**
|
|
224
|
-
declare const
|
|
226
|
+
/** Schema type name of the horizontal rule block. */
|
|
227
|
+
declare const horizontalRuleTypeName = "handbook.horizontalRule";
|
|
225
228
|
/**
|
|
226
|
-
* A
|
|
229
|
+
* A link on a run of guide text.
|
|
227
230
|
*
|
|
228
231
|
* @public
|
|
229
232
|
*/
|
|
@@ -232,5 +235,5 @@ type SanityHandbookLink = Strict<PortableTextObject> & {
|
|
|
232
235
|
/** Web address the link points to. */
|
|
233
236
|
href?: string;
|
|
234
237
|
};
|
|
235
|
-
export type { SanityHandbook, SanityHandbookBlockDefinition, SanityHandbookCallout, SanityHandbookCode, SanityHandbookConfig, SanityHandbookDocumentRole, SanityHandbookGuide, SanityHandbookGuideGroup, SanityHandbookHorizontalRule, SanityHandbookImage, SanityHandbookLink, SanityHandbookMetadata, SanityHandbookVideo };
|
|
238
|
+
export type { SanityHandbook, SanityHandbookBlockDefinition, SanityHandbookCallout, SanityHandbookCalloutVariant, SanityHandbookCode, SanityHandbookConfig, SanityHandbookDocumentRole, SanityHandbookGuide, SanityHandbookGuideGroup, SanityHandbookHorizontalRule, SanityHandbookImage, SanityHandbookLink, SanityHandbookMetadata, SanityHandbookVideo };
|
|
236
239
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["ComponentType","DocumentDefinition","PortableTextObject","SchemaTypeDefinition","_0","SanityHandbookMetadata","sideEffect","SanityHandbookDocumentRole","SanityHandbookBlockDefinition","SanityHandbookConfig","handbookPlugin","CurrentUser","StructureBuilder","handbookStructure","useIsHandbookEditor","KeyedSegment","PortableTextBlock","PortableTextObject","PortableTextSpan","PortableTextTextBlock","SanityDocument","Strict","T","K","SanityKeyedArray","SanityHandbookGuide","guideTypeName","SanityHandbookGuideGroup","SanityHandbook","handbookTypeName","SanityHandbookImage","imageTypeName","SanityHandbookVideo","videoTypeName","SanityHandbookCode","codeTypeName","SanityHandbookCalloutVariant","SanityHandbookCallout","calloutTypeName","SanityHandbookHorizontalRule","horizontalRuleTypeName","SanityHandbookLink"],"sources":["../src/plugin.ts","../src/lib/structure.ts","../src/hooks/use-is-handbook-editor.ts","../src/types.ts"],"mappings":";;;;YAoBY;;IAER,WAAWK;;YAIH;;IAER,WAAWA;;;;;;;;UASEA;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQeE;;EAEf;;EAEA;;EAEA,WAAWN;;;;;;;UAQIO;;EAEf,QAAQL;;EAER,WAAWH;IAAgB,OAAOE;;;;;;;;UAQnBO;;EAEf;;EAEA;;EAEA,OAAOF;;EAEP,SAASC;;EAET;;EAEA;;;;;;;;;;qBAWWE,iCAAc,OAAAD;;;;;;;;;;wBCxFXI,kBACd,kBAAkBD,kBAClB;EAAW,aAAaD;GACxB,gDAAkB;;;;;;;;wBCVJG,oBAAoB;;KCDxBO,OAAO,QAAQ,WAAWC,oBAAoBC,2BAA2BA,YAAYA,IAAID,EAAEC;;KAG3FC,iBAAiB,MAAMT,eAAeO;;;;;;KAOtCG,sBAAsBJ,OAAOD;EACvC,cAAcM;;EAEd;;EAEA;;EAEA,SAASF,iBAAiBR;;;cAIfU;;;;;;UAOIC;;EAEf;;EAEA,QAAQH,iBAAiBC;;;;;;;KAQfG,iBAAiBP,OAAOD;EAClC,cAAcS;;EAEd,QAAQL,iBAAiBG;;;cAIdE;;;;;;KAODC,sBAAsBT,OAAOJ;EACvC,cAAcc;;EAEd;IAAU;;;EAEV;;EAEA;;;cAIWA;;;;;;KAODC,sBAAsBX,OAAOJ;EACvC,cAAcgB;;EAEd;IAAU;;;EAEV;;;cAIWA;;;;;;KAODC,qBAAqBb,OAAOJ;EACtC,cAAckB;;EAEd;;EAEA;;;cAIWA;;;;;;KAODC;;;;;;KAOAC,wBAAwBhB,OAAOJ;EACzC,cAAcqB;;EAEd,SAASF;;EAET,MAAMZ,iBAAiBL,sBAAsBD;;;cAIlCoB;;;;;;KAODC,+BAA+BlB,OAAOJ;EAChD,cAAcuB;;;cAIHA;;;;;;KAODC,qBAAqBpB,OAAOJ;EACtC;;EAEA"}
|