@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/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 "@sanity/ui";
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 a schema author attaches to a field or document, shown wherever the Handbook renders it.
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
- /** Display title override for the field or document. */
20
+ /** Title to show instead of the schema title. */
20
21
  title?: string;
21
- /** Description shown beneath the field or document heading. */
22
+ /** Description shown below the field or document heading. */
22
23
  description?: string;
23
- /** Illustrative example value for the field. */
24
+ /** Example value for the field. */
24
25
  example?: string;
25
- /** Helpful tip displayed as a popover hint. */
26
+ /** Tip, shown as a hint icon. */
26
27
  tip?: string;
27
- /** Informational note displayed as a popover hint. */
28
+ /** Extra information, shown as a hint icon. */
28
29
  info?: string;
29
- /** Warning displayed as a popover hint. */
30
+ /** Warning, shown as a hint icon. */
30
31
  caution?: string;
31
32
  }
32
33
  /**
33
- * A named part a set of document types plays in the content model, shown as one sidebar section.
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
- /** Display title for the document role. */
39
+ /** Role title. */
39
40
  title: string;
40
- /** Brief description of the role's purpose. */
41
+ /** Short description of the role. */
41
42
  description?: string;
42
- /** Document definitions filling this role. */
43
+ /** Document definitions in the role. */
43
44
  documents: DocumentDefinition[];
44
45
  }
45
46
  /**
46
- * A Portable Text block a consumer adds to guide content, pairing its schema with how it renders.
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
- /** Sanity schema type definition for the custom block. */
52
+ /** Schema type definition for the block. */
52
53
  schema: SchemaTypeDefinition;
53
- /** React component for rendering the block in the Handbook viewer. */
54
+ /** Component that renders the block in the Handbook. */
54
55
  component: ComponentType<{
55
56
  value: PortableTextObject;
56
57
  }>;
57
58
  }
58
59
  /**
59
- * Everything the plugin accepts, of which only the document roles are required.
60
+ * Plugin configuration. Only `roles` is required.
60
61
  *
61
62
  * @public
62
63
  */
63
64
  interface SanityHandbookConfig {
64
- /** Title shown in the Studio tool navigation. */
65
+ /** Title in the Studio's tool menu. Defaults to `"Handbook"`. */
65
66
  title?: string;
66
- /** Heading displayed at the top of the sidebar. */
67
+ /** Heading at the top of the sidebar. Defaults to `"Handbook"`. */
67
68
  sidebarTitle?: string;
68
- /** Document roles, each shown as a labelled section in the sidebar. */
69
+ /** Document roles, each shown as a section in the sidebar. */
69
70
  roles: SanityHandbookDocumentRole[];
70
- /** Custom Portable Text block definitions for guide content. */
71
+ /** Custom Portable Text blocks for guides. Defaults to none. */
71
72
  blocks?: SanityHandbookBlockDefinition[];
72
- /** Email addresses permitted to edit Handbook documents. */
73
+ /** Email addresses of the people who can edit Handbook documents. Defaults to everyone. */
73
74
  editors?: string[];
74
- /** Fallback message shown when a field has no description. */
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
- * Creates a Handbook tool for Sanity Studio, generating documentation from document type schemas
79
- * alongside the Portable Text guides authored in the dataset.
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 - Plugin configuration.
82
- * @returns Sanity plugin definition.
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 the Structure tool items for Handbook documents, yielding nothing when the current user is
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 Sanity Structure builder instance.
91
- * @param context - The Structure context carrying the current user.
92
- * @param editors - Email addresses permitted to edit, defaulting to the configured list.
93
- * @returns The list items for the Handbook singleton and the guides list.
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 is permitted to edit Handbook content, treating an absent list as
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 permitted to edit, defaulting to the configured list.
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
- /** Drops a type's catch-all index signature, so a mistyped field name is an error rather than an unknown value. */
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 of objects each carrying the key Sanity assigns to array items, keeping members identifiable. */
109
+ /** Array whose items carry the `_key` Sanity gives array members. */
111
110
  type SanityKeyedArray<T> = (KeyedSegment & T)[];
112
111
  /**
113
- * A single Handbook page, authored as rich text and rendered in the tool.
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
- /** Display title for this guide. */
118
+ /** Guide title. */
120
119
  title: string;
121
- /** Brief description shown beneath the guide heading. */
120
+ /** Short description below the guide heading. */
122
121
  description?: string;
123
- /** Portable Text content of the guide. */
122
+ /** Portable Text content. */
124
123
  content: SanityKeyedArray<PortableTextBlock>;
125
124
  };
126
- /** Document type name of an individual guide. */
125
+ /** Schema type name of the guide document. */
127
126
  declare const guideTypeName = "handbook.guide";
128
127
  /**
129
- * A titled run of guides in the sidebar, holding them in the order they appear.
128
+ * A group of guides in the sidebar, in order.
130
129
  *
131
130
  * @public
132
131
  */
133
132
  interface SanityHandbookGuideGroup {
134
- /** Display title for this group in the sidebar. */
133
+ /** Group title in the sidebar. */
135
134
  title: string;
136
- /** Ordered array of guide references. */
135
+ /** Guides in the group, in order. */
137
136
  guides: SanityKeyedArray<SanityHandbookGuide>;
138
137
  }
139
138
  /**
140
- * The singleton naming every guide group and the order the sidebar lists them in.
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
- /** Ordered array of groups, each containing a title and guide references. */
145
+ /** Guide groups, in order. */
147
146
  groups: SanityKeyedArray<SanityHandbookGuideGroup>;
148
147
  };
149
- /** Document type name of the Handbook singleton. */
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
- * A highlighted message set apart from the surrounding guide text.
151
+ * An image in a guide, with its caption and alternative text.
155
152
  *
156
153
  * @public
157
154
  */
158
- type SanityHandbookCallout = Strict<PortableTextObject> & {
159
- _type: typeof calloutTypeName;
160
- /** Visual style and intent of the callout. */
161
- variant: CalloutVariant;
162
- /** Portable Text content displayed inside the callout, which offers no inline objects. */
163
- body: SanityKeyedArray<PortableTextTextBlock<PortableTextSpan>>;
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
- /** Type name of the callout block. */
166
- declare const calloutTypeName = "handbook.callout";
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 of source code, rendered with syntax highlighting for its language.
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
- /** Source code to display. */
191
+ /** Code to display. */
175
192
  code?: string;
176
- /** Programming language used for syntax highlighting. */
193
+ /** Language used for syntax highlighting. */
177
194
  language?: string;
178
195
  };
179
- /** Type name of the code block. */
196
+ /** Schema type name of the code block. */
180
197
  declare const codeTypeName = "handbook.code";
181
198
  /**
182
- * A divider between sections of a guide, carrying no authored content of its own.
199
+ * Kind of callout, which sets its icon and tone.
183
200
  *
184
201
  * @public
185
202
  */
186
- type SanityHandbookHorizontalRule = Strict<PortableTextObject> & {
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
- * An image placed in a guide, with the caption and alternative text shown alongside it.
205
+ * A highlighted message in a guide.
193
206
  *
194
207
  * @public
195
208
  */
196
- type SanityHandbookImage = Strict<PortableTextObject> & {
197
- _type: typeof imageTypeName;
198
- /** Uploaded image asset, narrowed by the query to the URL the viewer renders. */
199
- asset?: {
200
- url?: string;
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
- /** Type name of the image block. */
208
- declare const imageTypeName = "handbook.image";
216
+ /** Schema type name of the callout block. */
217
+ declare const calloutTypeName = "handbook.callout";
209
218
  /**
210
- * A video placed in a guide, with the caption shown beneath it.
219
+ * A divider between sections of a guide.
211
220
  *
212
221
  * @public
213
222
  */
214
- type SanityHandbookVideo = Strict<PortableTextObject> & {
215
- _type: typeof videoTypeName;
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
- /** Type name of the video block. */
224
- declare const videoTypeName = "handbook.video";
226
+ /** Schema type name of the horizontal rule block. */
227
+ declare const horizontalRuleTypeName = "handbook.horizontalRule";
225
228
  /**
226
- * A web address applied to a run of guide text.
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/plugin.ts","../src/lib/structure.ts","../src/hooks/use-is-handbook-editor.ts","../src/types.ts","../src/schemas/types/guide.ts","../src/schemas/types/handbook.ts","../src/blocks/callout/content.tsx","../src/schemas/blocks/callout.ts","../src/schemas/blocks/code.ts","../src/schemas/blocks/horizontal-rule.ts","../src/schemas/blocks/image.ts","../src/schemas/blocks/video.ts","../src/schemas/annotations/link.ts"],"mappings":";;;;;YAoBY;IACR,WAAW;;YAIH;IACR,WAAW;;;;;;;;UASE;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;;EAEf;;EAEA;;EAEA,WAAW;;;;;;;UAQI;;EAEf,QAAQ;;EAER,WAAW;IAAgB,OAAO;;;;;;;;UAQnB;;EAEf;;EAEA;;EAEA,OAAO;;EAEP,SAAS;;EAET;;EAEA;;;;;;;;;;qBAWW,iCAAc,OAAA;;;;;;;;;;;wBCpFX,kBACd,kBAAkB,kBAClB;EAAW,aAAa;GACxB,gDAAkB;;;;;;;;;wBCXJ,oBAAoB;;KCNxB,OAAO,QAAQ,WAAW,oBAAoB,2BAA2B,YAAY,IAAI,EAAE;;KAG3F,iBAAiB,MAAM,eAAe;;;;;;KCMtC,sBAAsB,OAAO;EACvC,cAAc;;EAEd;;EAEA;;EAEA,SAAS,iBAAiB;;;cAIf;;;;;;UCVI;;EAEf;;EAEA,QAAQ,iBAAiB;;;;;;;KAQf,iBAAiB,OAAO;EAClC,cAAc;;EAEd,QAAQ,iBAAiB;;;cAId;;KCzBD;;;;;;KCOA,wBAAwB,OAAO;EACzC,cAAc;;EAEd,SAAS;;EAET,MAAM,iBAAiB,sBAAsB;;;cAIlC;;;;;;KCbD,qBAAqB,OAAO;EACtC,cAAc;;EAEd;;EAEA;;;cAIW;;;;;;KCTD,+BAA+B,OAAO;EAChD,cAAc;;;cAIH;;;;;;KCLD,sBAAsB,OAAO;EACvC,cAAc;;EAEd;IAAU;;;EAEV;;EAEA;;;cAIW;;;;;;KCXD,sBAAsB,OAAO;EACvC,cAAc;;EAEd;IAAU;;;EAEV;;;cAIW;;;;;;KCZD,qBAAqB,OAAO;EACtC;;EAEA"}
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/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