@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.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { createContext, createElement, useContext, useEffect, useRef, useState } from "react";
|
|
1
2
|
import { CommandList, PreviewCard, SanityDefaultPreview, defineArrayMember, defineField, definePlugin, defineType, useClient, useCurrentUser, useSchema } from "sanity";
|
|
2
3
|
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { createContext, createElement, useContext, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { Box, Button, Card, Flex, Heading, Layer, LayerProvider, Stack, Text, useClickOutsideEvent, useElementSize, useTheme_v2 } from "@sanity/ui";
|
|
6
|
-
import { Code } from "@sanity/ui/code";
|
|
7
6
|
import { Pane, PaneContent, PaneLayout } from "sanity/structure";
|
|
8
7
|
import { PaneContext, PaneLayoutContext } from "sanity/_singletons";
|
|
9
8
|
import { ArrowLeftIcon } from "@sanity/icons/ArrowLeft";
|
|
@@ -11,43 +10,19 @@ import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
|
|
|
11
10
|
import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
|
|
12
11
|
import { Popover } from "@sanity/ui/popover";
|
|
13
12
|
import { PortableText } from "@portabletext/react";
|
|
14
|
-
|
|
13
|
+
import { Code } from "@sanity/ui/code";
|
|
14
|
+
/** Default props for the plugin's own icons. Icons from `@sanity/icons` already match the Studio. */
|
|
15
15
|
const defaultIconProps = {
|
|
16
16
|
width: "1em",
|
|
17
17
|
height: "1em",
|
|
18
18
|
strokeWidth: 1.5
|
|
19
19
|
};
|
|
20
|
-
function BookOpenTextIcon(props) {
|
|
21
|
-
let $ = c(8), t0, t1, t2, t3, t4, t5;
|
|
22
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M12 7v14" }), t1 = /* @__PURE__ */ jsx("path", { d: "M16 12h2" }), t2 = /* @__PURE__ */ jsx("path", { d: "M16 8h2" }), t3 = /* @__PURE__ */ jsx("path", { d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z" }), t4 = /* @__PURE__ */ jsx("path", { d: "M6 12h2" }), t5 = /* @__PURE__ */ jsx("path", { d: "M6 8h2" }), $[0] = t0, $[1] = t1, $[2] = t2, $[3] = t3, $[4] = t4, $[5] = t5) : (t0 = $[0], t1 = $[1], t2 = $[2], t3 = $[3], t4 = $[4], t5 = $[5]);
|
|
23
|
-
let t6;
|
|
24
|
-
return $[6] === props ? t6 = $[7] : (t6 = /* @__PURE__ */ jsxs("svg", {
|
|
25
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
26
|
-
width: 24,
|
|
27
|
-
height: 24,
|
|
28
|
-
viewBox: "0 0 24 24",
|
|
29
|
-
fill: "none",
|
|
30
|
-
stroke: "currentColor",
|
|
31
|
-
strokeWidth: 2,
|
|
32
|
-
strokeLinecap: "round",
|
|
33
|
-
strokeLinejoin: "round",
|
|
34
|
-
...props,
|
|
35
|
-
children: [
|
|
36
|
-
t0,
|
|
37
|
-
t1,
|
|
38
|
-
t2,
|
|
39
|
-
t3,
|
|
40
|
-
t4,
|
|
41
|
-
t5
|
|
42
|
-
]
|
|
43
|
-
}), $[6] = props, $[7] = t6), t6;
|
|
44
|
-
}
|
|
45
20
|
/**
|
|
46
|
-
*
|
|
21
|
+
* Wraps an SVG icon component for use in the Studio.
|
|
47
22
|
*
|
|
48
|
-
* @param icon - The icon
|
|
49
|
-
* @param props -
|
|
50
|
-
* @returns
|
|
23
|
+
* @param icon - The icon to wrap.
|
|
24
|
+
* @param props - Props that override the Studio icon defaults.
|
|
25
|
+
* @returns An icon component.
|
|
51
26
|
*/
|
|
52
27
|
function createSanityIcon(icon, props) {
|
|
53
28
|
let Icon = icon;
|
|
@@ -59,123 +34,59 @@ function createSanityIcon(icon, props) {
|
|
|
59
34
|
}
|
|
60
35
|
return SanityIcon;
|
|
61
36
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
children
|
|
110
|
-
}), $[8] = children, $[9] = muted, $[10] = t3) : t3 = $[10];
|
|
111
|
-
let t4;
|
|
112
|
-
return $[11] !== props || $[12] !== t1 || $[13] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, {
|
|
113
|
-
paddingY: 1,
|
|
114
|
-
paddingLeft: 3,
|
|
115
|
-
style: t1,
|
|
116
|
-
...props,
|
|
117
|
-
children: t3
|
|
118
|
-
}), $[11] = props, $[12] = t1, $[13] = t3, $[14] = t4) : t4 = $[14], t4;
|
|
119
|
-
}
|
|
120
|
-
function PortableHeading(props) {
|
|
121
|
-
let $ = c(2), t0;
|
|
122
|
-
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
|
|
123
|
-
as: "h2",
|
|
124
|
-
size: 1,
|
|
125
|
-
weight: "medium",
|
|
126
|
-
...props
|
|
127
|
-
}), $[0] = props, $[1] = t0), t0;
|
|
128
|
-
}
|
|
129
|
-
function PortableParagraph(props) {
|
|
130
|
-
let $ = c(2), t0;
|
|
131
|
-
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
|
|
132
|
-
size: 1,
|
|
133
|
-
...props
|
|
134
|
-
}), $[0] = props, $[1] = t0), t0;
|
|
135
|
-
}
|
|
136
|
-
function ParagraphStyle(t0) {
|
|
137
|
-
let $ = c(2), { children } = t0, t1;
|
|
138
|
-
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableParagraph, { children }), $[0] = children, $[1] = t1), t1;
|
|
139
|
-
}
|
|
140
|
-
function HeadingStyle(t0) {
|
|
141
|
-
let $ = c(2), { children } = t0, t1;
|
|
142
|
-
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableHeading, { children }), $[0] = children, $[1] = t1), t1;
|
|
143
|
-
}
|
|
144
|
-
function BlockquoteStyle(t0) {
|
|
145
|
-
let $ = c(2), { children } = t0, t1;
|
|
146
|
-
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableBlockquote, { children }), $[0] = children, $[1] = t1), t1;
|
|
37
|
+
/** Whether this is a development build, the only kind in which the plugin logs. */
|
|
38
|
+
const isDevelopment = process.env.NODE_ENV === "development", prefixStyle = "color: #2276fc";
|
|
39
|
+
/**
|
|
40
|
+
* Creates a logger that prefixes messages with the plugin's name and only logs in development builds.
|
|
41
|
+
* Browser consoles show the prefix in blue.
|
|
42
|
+
*
|
|
43
|
+
* @param name - The package name to prefix messages with.
|
|
44
|
+
* @returns Functions that log progress, a warning, or an error, or format a message to throw.
|
|
45
|
+
*/
|
|
46
|
+
function createLogger(name) {
|
|
47
|
+
let prefix = `[${name}]`;
|
|
48
|
+
/**
|
|
49
|
+
* Prefixes a message with the package name.
|
|
50
|
+
*
|
|
51
|
+
* @param message - The message.
|
|
52
|
+
* @returns The prefixed message.
|
|
53
|
+
*/
|
|
54
|
+
function format(message) {
|
|
55
|
+
return `${prefix} ${message}`;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
/**
|
|
59
|
+
* Logs progress worth seeing, such as what a build step did, in development builds only.
|
|
60
|
+
*
|
|
61
|
+
* @param message - What happened.
|
|
62
|
+
*/
|
|
63
|
+
info(message) {
|
|
64
|
+
isDevelopment && console.info(`%c${prefix}%c ${message}`, prefixStyle, "");
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Logs a warning about something the plugin recovered from, in development builds only.
|
|
68
|
+
*
|
|
69
|
+
* @param message - What happened and what to do about it.
|
|
70
|
+
*/
|
|
71
|
+
warn(message) {
|
|
72
|
+
isDevelopment && console.warn(`%c${prefix}%c ${message}`, prefixStyle, "");
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Logs an error the plugin couldn't recover from, in development builds only.
|
|
76
|
+
*
|
|
77
|
+
* @param message - What went wrong and what to do about it.
|
|
78
|
+
*/
|
|
79
|
+
error(message) {
|
|
80
|
+
isDevelopment && console.error(`%c${prefix}%c ${message}`, prefixStyle, "");
|
|
81
|
+
},
|
|
82
|
+
format
|
|
83
|
+
};
|
|
147
84
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
description: "Link applied to the selected text.",
|
|
152
|
-
preview: {
|
|
153
|
-
select: { href: "href" },
|
|
154
|
-
prepare(selection) {
|
|
155
|
-
let { href } = selection;
|
|
156
|
-
return { title: href ?? "Link" };
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
fields: [defineField({
|
|
160
|
-
name: "href",
|
|
161
|
-
title: "URL",
|
|
162
|
-
type: "url",
|
|
163
|
-
description: "Web address destination for this link. Supports http, https, mailto, and tel schemes.",
|
|
164
|
-
validation: (rule) => rule.uri({ scheme: [
|
|
165
|
-
"http",
|
|
166
|
-
"https",
|
|
167
|
-
"mailto",
|
|
168
|
-
"tel"
|
|
169
|
-
] })
|
|
170
|
-
})]
|
|
171
|
-
});
|
|
172
|
-
function InfoIcon(props) {
|
|
85
|
+
/** Package name, used as the prefix on every logged message. */
|
|
86
|
+
const pluginName = "@driftime/sanity-plugin-handbook", logger = createLogger(pluginName), guideTypeName = "handbook.guide", handbookTypeName = "handbook.handbook", imageTypeName = "handbook.image", videoTypeName = "handbook.video", codeTypeName = "handbook.code", calloutTypeName = "handbook.callout", horizontalRuleTypeName = "handbook.horizontalRule", singletonTypes = /* @__PURE__ */ new Set([handbookTypeName]), documentTypes = /* @__PURE__ */ new Set([handbookTypeName, guideTypeName]);
|
|
87
|
+
function BookTextIcon(props) {
|
|
173
88
|
let $ = c(5), t0, t1, t2;
|
|
174
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("
|
|
175
|
-
cx: "12",
|
|
176
|
-
cy: "12",
|
|
177
|
-
r: "10"
|
|
178
|
-
}), t1 = /* @__PURE__ */ jsx("path", { d: "M12 16v-4" }), t2 = /* @__PURE__ */ jsx("path", { d: "M12 8h.01" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
89
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20" }), t1 = /* @__PURE__ */ jsx("path", { d: "M8 11h8" }), t2 = /* @__PURE__ */ jsx("path", { d: "M8 7h6" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
179
90
|
let t3;
|
|
180
91
|
return $[3] === props ? t3 = $[4] : (t3 = /* @__PURE__ */ jsxs("svg", {
|
|
181
92
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -195,310 +106,410 @@ function InfoIcon(props) {
|
|
|
195
106
|
]
|
|
196
107
|
}), $[3] = props, $[4] = t3), t3;
|
|
197
108
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
t0,
|
|
215
|
-
t1,
|
|
216
|
-
t2
|
|
217
|
-
]
|
|
218
|
-
}), $[3] = props, $[4] = t3), t3;
|
|
109
|
+
/**
|
|
110
|
+
* Checks whether a value is present. `false`, blank strings, and empty plain objects count as absent,
|
|
111
|
+
* as does an array with no present elements.
|
|
112
|
+
*
|
|
113
|
+
* @param value - The value to check.
|
|
114
|
+
* @returns True if the value is present.
|
|
115
|
+
*/
|
|
116
|
+
function isDefined(value) {
|
|
117
|
+
if (value == null || value === !1) return !1;
|
|
118
|
+
if (typeof value == "string") return value.trim() !== "";
|
|
119
|
+
if (Array.isArray(value)) return value.some((element) => isDefined(element));
|
|
120
|
+
if (typeof value == "object") {
|
|
121
|
+
let prototype = Reflect.getPrototypeOf(value);
|
|
122
|
+
return prototype !== Object.prototype && prototype !== null || Object.keys(value).length > 0;
|
|
123
|
+
}
|
|
124
|
+
return !0;
|
|
219
125
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
t2
|
|
239
|
-
]
|
|
240
|
-
}), $[3] = props, $[4] = t3), t3;
|
|
126
|
+
/**
|
|
127
|
+
* Converts a string to another case.
|
|
128
|
+
*
|
|
129
|
+
* @param value - The string to convert.
|
|
130
|
+
* @param format - The case to convert to.
|
|
131
|
+
* @returns The converted string.
|
|
132
|
+
*/
|
|
133
|
+
function convertCase(value, format) {
|
|
134
|
+
let words = value.replaceAll(/(?<lower>[a-z0-9])(?<upper>[A-Z])/gu, "$<lower> $<upper>").replaceAll(/[-_\s]+/gu, " ").trim().toLowerCase();
|
|
135
|
+
switch (format) {
|
|
136
|
+
case "kebab": return words.replaceAll(/\s+/gu, "-");
|
|
137
|
+
case "snake": return words.replaceAll(/\s+/gu, "_");
|
|
138
|
+
case "camel": return words.replaceAll(/\s+(?<character>.)/gu, (_match, character) => character.toUpperCase());
|
|
139
|
+
case "pascal": return words.replaceAll(/(?:^|\s+)(?<character>.)/gu, (_match, character) => character.toUpperCase());
|
|
140
|
+
case "title": return words.replaceAll(/\b\w/gu, (character) => character.toUpperCase());
|
|
141
|
+
case "sentence": return words.replaceAll(/^(?<character>.)/gu, (character) => character.toUpperCase());
|
|
142
|
+
default: return value;
|
|
143
|
+
}
|
|
241
144
|
}
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Checks whether a value is an object whose keys can be read.
|
|
147
|
+
*
|
|
148
|
+
* @param value - The value to check.
|
|
149
|
+
* @returns True if the value is an object.
|
|
150
|
+
*/
|
|
151
|
+
function isRecord(value) {
|
|
152
|
+
return typeof value == "object" && !!value;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Reads a nested value by following a path of keys.
|
|
156
|
+
*
|
|
157
|
+
* @param value - The object to read from.
|
|
158
|
+
* @param path - The keys to follow.
|
|
159
|
+
* @returns The value, or undefined when the path doesn't exist.
|
|
160
|
+
*/
|
|
161
|
+
function readPath(value, path) {
|
|
162
|
+
let current = value;
|
|
163
|
+
for (let segment of path) {
|
|
164
|
+
if (!isRecord(current)) return;
|
|
165
|
+
current = current[segment];
|
|
255
166
|
}
|
|
256
|
-
|
|
257
|
-
function CalloutContent(t0) {
|
|
258
|
-
let $ = c(17), children, props, variant;
|
|
259
|
-
$[0] === t0 ? (children = $[1], props = $[2], variant = $[3]) : ({variant, children, ...props} = t0, $[0] = t0, $[1] = children, $[2] = props, $[3] = variant);
|
|
260
|
-
let { icon: Icon, tone } = presentation[variant], t1;
|
|
261
|
-
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
262
|
-
flexShrink: 0,
|
|
263
|
-
marginTop: "-2px",
|
|
264
|
-
fontSize: "16px",
|
|
265
|
-
color: "var(--card-icon-color)"
|
|
266
|
-
}, $[4] = t1) : t1 = $[4];
|
|
267
|
-
let t2;
|
|
268
|
-
$[5] === Icon ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx("div", {
|
|
269
|
-
style: t1,
|
|
270
|
-
children: /* @__PURE__ */ jsx(Icon, { ...defaultIconProps })
|
|
271
|
-
}), $[5] = Icon, $[6] = t2);
|
|
272
|
-
let t3;
|
|
273
|
-
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = { color: "var(--card-icon-color)" }, $[7] = t3) : t3 = $[7];
|
|
274
|
-
let t4;
|
|
275
|
-
$[8] === children ? t4 = $[9] : (t4 = /* @__PURE__ */ jsx(Text, {
|
|
276
|
-
size: 1,
|
|
277
|
-
style: t3,
|
|
278
|
-
children
|
|
279
|
-
}), $[8] = children, $[9] = t4);
|
|
280
|
-
let t5;
|
|
281
|
-
$[10] !== t2 || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, {
|
|
282
|
-
align: "flex-start",
|
|
283
|
-
gap: 3,
|
|
284
|
-
children: [t2, t4]
|
|
285
|
-
}), $[10] = t2, $[11] = t4, $[12] = t5) : t5 = $[12];
|
|
286
|
-
let t6;
|
|
287
|
-
return $[13] !== props || $[14] !== t5 || $[15] !== tone ? (t6 = /* @__PURE__ */ jsx(Card, {
|
|
288
|
-
padding: 4,
|
|
289
|
-
radius: 2,
|
|
290
|
-
tone,
|
|
291
|
-
...props,
|
|
292
|
-
children: t5
|
|
293
|
-
}), $[13] = props, $[14] = t5, $[15] = tone, $[16] = t6) : t6 = $[16], t6;
|
|
294
|
-
}
|
|
295
|
-
function CalloutPreview(t0) {
|
|
296
|
-
let $ = c(8), { variant, body } = t0, t1 = variant ?? "tip", t2;
|
|
297
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
298
|
-
display: "flex",
|
|
299
|
-
flexDirection: "column",
|
|
300
|
-
gap: 12
|
|
301
|
-
}, $[0] = t2) : t2 = $[0];
|
|
302
|
-
let t3;
|
|
303
|
-
$[1] === body ? t3 = $[2] : (t3 = body?.map(_temp2$1), $[1] = body, $[2] = t3);
|
|
304
|
-
let t4;
|
|
305
|
-
$[3] === t3 ? t4 = $[4] : (t4 = /* @__PURE__ */ jsx("div", {
|
|
306
|
-
style: t2,
|
|
307
|
-
children: t3
|
|
308
|
-
}), $[3] = t3, $[4] = t4);
|
|
309
|
-
let t5;
|
|
310
|
-
return $[5] !== t1 || $[6] !== t4 ? (t5 = /* @__PURE__ */ jsx(CalloutContent, {
|
|
311
|
-
variant: t1,
|
|
312
|
-
children: t4
|
|
313
|
-
}), $[5] = t1, $[6] = t4, $[7] = t5) : t5 = $[7], t5;
|
|
314
|
-
}
|
|
315
|
-
function _temp2$1(t0) {
|
|
316
|
-
let { _key, children } = t0;
|
|
317
|
-
return /* @__PURE__ */ jsx("div", {
|
|
318
|
-
style: { whiteSpace: "pre-wrap" },
|
|
319
|
-
children: children.map(_temp$3).join("")
|
|
320
|
-
}, _key);
|
|
167
|
+
return current;
|
|
321
168
|
}
|
|
322
|
-
|
|
323
|
-
|
|
169
|
+
/** Share of the space the content pane takes relative to the sidebar. */
|
|
170
|
+
const contentSpacing = {
|
|
171
|
+
section: 48,
|
|
172
|
+
paragraph: 16,
|
|
173
|
+
heading: 48,
|
|
174
|
+
media: 24,
|
|
175
|
+
callout: 32,
|
|
176
|
+
blockquote: 32,
|
|
177
|
+
list: 32,
|
|
178
|
+
nestedList: 12,
|
|
179
|
+
rule: 40
|
|
180
|
+
}, assetUrlFragment = "\"asset\": { \"url\": asset.asset->url }", guideFragment = `...@-> {
|
|
181
|
+
...,
|
|
182
|
+
content[] { ..., ${`
|
|
183
|
+
_type == "${imageTypeName}" => { ..., ${assetUrlFragment} },
|
|
184
|
+
_type == "${videoTypeName}" => { ..., ${assetUrlFragment} }
|
|
185
|
+
`} }
|
|
186
|
+
}`;
|
|
187
|
+
/**
|
|
188
|
+
* Defines a GROQ query typed with its result, so fetches infer the result type.
|
|
189
|
+
*
|
|
190
|
+
* @param query - The GROQ query.
|
|
191
|
+
* @returns The query, typed with its result.
|
|
192
|
+
*/
|
|
193
|
+
function defineTypedQuery(query) {
|
|
194
|
+
return query;
|
|
324
195
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
fill: "none",
|
|
335
|
-
stroke: "currentColor",
|
|
336
|
-
strokeWidth: 2,
|
|
337
|
-
strokeLinecap: "round",
|
|
338
|
-
strokeLinejoin: "round",
|
|
339
|
-
...props,
|
|
340
|
-
children: t0
|
|
341
|
-
}), $[1] = props, $[2] = t1), t1;
|
|
196
|
+
/**
|
|
197
|
+
* Runs a typed query, returning undefined instead of null when nothing matches.
|
|
198
|
+
*
|
|
199
|
+
* @param client - The Sanity client.
|
|
200
|
+
* @param query - The typed query.
|
|
201
|
+
* @returns The result, or undefined when nothing matches.
|
|
202
|
+
*/
|
|
203
|
+
async function fetchQuery(client, query) {
|
|
204
|
+
return await client.fetch(query) ?? void 0;
|
|
342
205
|
}
|
|
343
|
-
/**
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
{
|
|
378
|
-
title: "Information",
|
|
379
|
-
value: "info"
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
title: "Warning",
|
|
383
|
-
value: "warning"
|
|
384
|
-
}
|
|
385
|
-
],
|
|
386
|
-
layout: "radio",
|
|
387
|
-
direction: "horizontal"
|
|
388
|
-
}
|
|
389
|
-
}), defineField({
|
|
390
|
-
name: "body",
|
|
391
|
-
type: "array",
|
|
392
|
-
description: "Content displayed inside the callout. Supports inline formatting and links.",
|
|
393
|
-
of: [defineArrayMember({
|
|
394
|
-
name: "block",
|
|
395
|
-
type: "block",
|
|
396
|
-
styles: [{
|
|
397
|
-
title: "Normal",
|
|
398
|
-
value: "normal",
|
|
399
|
-
component: ParagraphStyle
|
|
400
|
-
}],
|
|
401
|
-
lists: [],
|
|
402
|
-
marks: {
|
|
403
|
-
decorators: [
|
|
404
|
-
{
|
|
405
|
-
title: "Bold",
|
|
406
|
-
value: "strong"
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
title: "Italic",
|
|
410
|
-
value: "em"
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
title: "Strikethrough",
|
|
414
|
-
value: "strike-through"
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
title: "Code",
|
|
418
|
-
value: "code",
|
|
419
|
-
component: CodeDecorator
|
|
420
|
-
}
|
|
421
|
-
],
|
|
422
|
-
annotations: [linkAnnotation]
|
|
423
|
-
}
|
|
424
|
-
})]
|
|
425
|
-
})]
|
|
426
|
-
});
|
|
427
|
-
function CodeContent(t0) {
|
|
428
|
-
let $ = c(14), code, language, props, style;
|
|
429
|
-
$[0] === t0 ? (code = $[1], language = $[2], props = $[3], style = $[4]) : ({code, language, style, ...props} = t0, $[0] = t0, $[1] = code, $[2] = language, $[3] = props, $[4] = style);
|
|
430
|
-
let t1;
|
|
431
|
-
$[5] === style ? t1 = $[6] : (t1 = {
|
|
432
|
-
overflowX: "auto",
|
|
433
|
-
...style
|
|
434
|
-
}, $[5] = style, $[6] = t1);
|
|
435
|
-
let t2;
|
|
436
|
-
$[7] !== code || $[8] !== language ? (t2 = /* @__PURE__ */ jsx(Code, {
|
|
437
|
-
size: 1,
|
|
438
|
-
language,
|
|
439
|
-
children: code
|
|
440
|
-
}), $[7] = code, $[8] = language, $[9] = t2) : t2 = $[9];
|
|
206
|
+
/** Handbook document with its guide references expanded. */
|
|
207
|
+
const handbookQuery = defineTypedQuery(`
|
|
208
|
+
*[_type == "${handbookTypeName}"][0] {
|
|
209
|
+
...,
|
|
210
|
+
groups[] {
|
|
211
|
+
...,
|
|
212
|
+
guides[] {
|
|
213
|
+
...,
|
|
214
|
+
${guideFragment}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
`), handbookDocumentsQuery = defineTypedQuery(`*[_type == "${handbookTypeName}" || _type == "${guideTypeName}"]`);
|
|
219
|
+
/**
|
|
220
|
+
* Fetches the Handbook document with its guides expanded, refetching when any Handbook document changes.
|
|
221
|
+
*
|
|
222
|
+
* @returns The Handbook document, and whether it's still loading.
|
|
223
|
+
*/
|
|
224
|
+
function useHandbookDocument() {
|
|
225
|
+
let $ = c(7), t0;
|
|
226
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "2026-01-01" }, $[0] = t0) : t0 = $[0];
|
|
227
|
+
let client = useClient(t0), [handbook, setHandbook] = useState(void 0), [loading, setLoading] = useState(!0), t1, t2;
|
|
228
|
+
$[1] === client ? (t1 = $[2], t2 = $[3]) : (t1 = () => {
|
|
229
|
+
let fetchHandbook = async function fetchHandbook() {
|
|
230
|
+
setHandbook(await fetchQuery(client, handbookQuery)), setLoading(!1);
|
|
231
|
+
};
|
|
232
|
+
fetchHandbook();
|
|
233
|
+
let subscription = client.listen(handbookDocumentsQuery).subscribe(() => {
|
|
234
|
+
fetchHandbook();
|
|
235
|
+
});
|
|
236
|
+
return () => {
|
|
237
|
+
subscription.unsubscribe();
|
|
238
|
+
};
|
|
239
|
+
}, t2 = [client], $[1] = client, $[2] = t1, $[3] = t2), useEffect(t1, t2);
|
|
441
240
|
let t3;
|
|
442
|
-
return $[
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
style: t1,
|
|
447
|
-
...props,
|
|
448
|
-
children: t2
|
|
449
|
-
}), $[10] = props, $[11] = t1, $[12] = t2, $[13] = t3) : t3 = $[13], t3;
|
|
241
|
+
return $[4] !== handbook || $[5] !== loading ? (t3 = {
|
|
242
|
+
handbook,
|
|
243
|
+
loading
|
|
244
|
+
}, $[4] = handbook, $[5] = loading, $[6] = t3) : t3 = $[6], t3;
|
|
450
245
|
}
|
|
246
|
+
const HandbookContext = createContext(void 0);
|
|
451
247
|
/**
|
|
452
|
-
*
|
|
453
|
-
* no keys as absent. An array is absent unless one of its elements is itself present, while anything
|
|
454
|
-
* built from a class counts as present on existence alone. Not intended for boolean flags.
|
|
248
|
+
* Reads the Handbook context.
|
|
455
249
|
*
|
|
456
|
-
* @
|
|
457
|
-
* @
|
|
250
|
+
* @returns The plugin configuration and the shared pane state.
|
|
251
|
+
* @throws When used outside the provider.
|
|
458
252
|
*/
|
|
459
|
-
function
|
|
460
|
-
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
if (typeof value == "object") {
|
|
464
|
-
let prototype = Reflect.getPrototypeOf(value);
|
|
465
|
-
return prototype !== Object.prototype && prototype !== null || Object.keys(value).length > 0;
|
|
466
|
-
}
|
|
467
|
-
return !0;
|
|
253
|
+
function useHandbookContext() {
|
|
254
|
+
let handbookContext = useContext(HandbookContext);
|
|
255
|
+
if (!isDefined(handbookContext)) throw Error(logger.format("Handbook context is only available inside the Handbook provider."));
|
|
256
|
+
return handbookContext;
|
|
468
257
|
}
|
|
469
258
|
/**
|
|
470
|
-
*
|
|
259
|
+
* Provides the plugin configuration, the Handbook document, and the tab state shared by the sidebar and
|
|
260
|
+
* content panes.
|
|
471
261
|
*
|
|
472
|
-
* @
|
|
473
|
-
* @param format - The target casing format.
|
|
474
|
-
* @returns The converted string.
|
|
262
|
+
* @returns The provider.
|
|
475
263
|
*/
|
|
476
|
-
function
|
|
477
|
-
let
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}), $[0] = code, $[1] = language, $[2] = t1) : t1 = $[2], t1;
|
|
264
|
+
function HandbookProvider(t0) {
|
|
265
|
+
let $ = c(12), { sidebarTitle, roles, blocks, undocumentedFieldMessage, children } = t0, [activeTab, setActiveTab] = useState(void 0), [sidebarExpanded, setSidebarExpanded] = useState(!0), { handbook, loading } = useHandbookDocument(), t1;
|
|
266
|
+
$[0] !== activeTab || $[1] !== blocks || $[2] !== handbook || $[3] !== loading || $[4] !== roles || $[5] !== sidebarExpanded || $[6] !== sidebarTitle || $[7] !== undocumentedFieldMessage ? (t1 = {
|
|
267
|
+
sidebarTitle,
|
|
268
|
+
roles,
|
|
269
|
+
blocks,
|
|
270
|
+
undocumentedFieldMessage,
|
|
271
|
+
activeTab,
|
|
272
|
+
sidebarExpanded,
|
|
273
|
+
loading,
|
|
274
|
+
handbook,
|
|
275
|
+
setActiveTab,
|
|
276
|
+
setSidebarExpanded
|
|
277
|
+
}, $[0] = activeTab, $[1] = blocks, $[2] = handbook, $[3] = loading, $[4] = roles, $[5] = sidebarExpanded, $[6] = sidebarTitle, $[7] = undocumentedFieldMessage, $[8] = t1) : t1 = $[8];
|
|
278
|
+
let t2;
|
|
279
|
+
return $[9] !== children || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(HandbookContext, {
|
|
280
|
+
value: t1,
|
|
281
|
+
children
|
|
282
|
+
}), $[9] = children, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
|
|
496
283
|
}
|
|
497
|
-
function
|
|
498
|
-
let $ = c(
|
|
499
|
-
$[0] ===
|
|
284
|
+
function PaneHeader(t0) {
|
|
285
|
+
let $ = c(46), backButton, props, style, title;
|
|
286
|
+
$[0] === t0 ? (backButton = $[1], props = $[2], style = $[3], title = $[4]) : ({title, backButton, style, ...props} = t0, $[0] = t0, $[1] = backButton, $[2] = props, $[3] = style, $[4] = title);
|
|
287
|
+
let { color } = useTheme_v2(), pane = useContext(PaneContext), paneSize = useElementSize(pane?.rootElement ?? null), collapsed = pane?.collapsed ?? !1, isLast = pane?.isLast ?? !1, paneHeight = paneSize?.border.height ?? 0, collapsedWidth = paneHeight > 0 ? paneHeight : window.innerHeight, { bg, fg } = color.selectable.default.enabled, t1;
|
|
288
|
+
$[5] !== collapsed || $[6] !== pane ? (t1 = function handleTitleClick() {
|
|
289
|
+
collapsed || pane?.collapse();
|
|
290
|
+
}, $[5] = collapsed, $[6] = pane, $[7] = t1) : t1 = $[7];
|
|
291
|
+
let handleTitleClick = t1, t2;
|
|
292
|
+
$[8] !== collapsed || $[9] !== pane ? (t2 = function handleLayoutClick() {
|
|
293
|
+
collapsed && pane?.expand();
|
|
294
|
+
}, $[8] = collapsed, $[9] = pane, $[10] = t2) : t2 = $[10];
|
|
295
|
+
let handleLayoutClick = t2, t3 = collapsed ? "" : void 0, t4;
|
|
296
|
+
$[11] === style ? t4 = $[12] : (t4 = {
|
|
297
|
+
lineHeight: 0,
|
|
298
|
+
position: "sticky",
|
|
299
|
+
top: 0,
|
|
300
|
+
...style
|
|
301
|
+
}, $[11] = style, $[12] = t4);
|
|
302
|
+
let t5 = collapsed ? "" : void 0, t6 = collapsed ? collapsedWidth : void 0, t7 = collapsed ? "rotate(90deg)" : void 0, t8;
|
|
303
|
+
$[13] !== t6 || $[14] !== t7 ? (t8 = {
|
|
304
|
+
width: t6,
|
|
305
|
+
transform: t7,
|
|
306
|
+
transformOrigin: "calc(51px / 2)"
|
|
307
|
+
}, $[13] = t6, $[14] = t7, $[15] = t8) : t8 = $[15];
|
|
308
|
+
let t9;
|
|
309
|
+
$[16] === backButton ? t9 = $[17] : (t9 = isDefined(backButton) && /* @__PURE__ */ jsx(Box, {
|
|
310
|
+
flex: "none",
|
|
311
|
+
children: backButton
|
|
312
|
+
}), $[16] = backButton, $[17] = t9);
|
|
313
|
+
let t10 = isDefined(backButton) ? 1 : 2, t11 = isLast && !collapsed ? -1 : 0, t12;
|
|
314
|
+
$[18] === bg ? t12 = $[19] : (t12 = {
|
|
315
|
+
backgroundColor: bg,
|
|
316
|
+
minWidth: 0
|
|
317
|
+
}, $[18] = bg, $[19] = t12);
|
|
318
|
+
let t13;
|
|
319
|
+
$[20] === fg ? t13 = $[21] : (t13 = {
|
|
320
|
+
color: fg,
|
|
321
|
+
cursor: "default",
|
|
322
|
+
minWidth: 0,
|
|
323
|
+
outline: "none"
|
|
324
|
+
}, $[20] = fg, $[21] = t13);
|
|
325
|
+
let t14;
|
|
326
|
+
$[22] !== t13 || $[23] !== title ? (t14 = /* @__PURE__ */ jsx(Flex, {
|
|
327
|
+
align: "center",
|
|
328
|
+
gap: 1,
|
|
329
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
330
|
+
size: 1,
|
|
331
|
+
textOverflow: "ellipsis",
|
|
332
|
+
weight: "semibold",
|
|
333
|
+
style: t13,
|
|
334
|
+
children: title
|
|
335
|
+
})
|
|
336
|
+
}), $[22] = t13, $[23] = title, $[24] = t14) : t14 = $[24];
|
|
337
|
+
let t15;
|
|
338
|
+
$[25] !== handleTitleClick || $[26] !== t10 || $[27] !== t11 || $[28] !== t12 || $[29] !== t14 ? (t15 = /* @__PURE__ */ jsx(Card, {
|
|
339
|
+
flex: 1,
|
|
340
|
+
onClick: handleTitleClick,
|
|
341
|
+
padding: 2,
|
|
342
|
+
paddingLeft: t10,
|
|
343
|
+
tabIndex: t11,
|
|
344
|
+
style: t12,
|
|
345
|
+
__unstable_focusRing: !0,
|
|
346
|
+
children: t14
|
|
347
|
+
}), $[25] = handleTitleClick, $[26] = t10, $[27] = t11, $[28] = t12, $[29] = t14, $[30] = t15) : t15 = $[30];
|
|
348
|
+
let t16;
|
|
349
|
+
$[31] !== t15 || $[32] !== t9 ? (t16 = /* @__PURE__ */ jsxs(Flex, {
|
|
350
|
+
align: "flex-start",
|
|
351
|
+
gap: 3,
|
|
352
|
+
children: [t9, t15]
|
|
353
|
+
}), $[31] = t15, $[32] = t9, $[33] = t16) : t16 = $[33];
|
|
354
|
+
let t17;
|
|
355
|
+
$[34] !== handleLayoutClick || $[35] !== t16 || $[36] !== t8 ? (t17 = /* @__PURE__ */ jsx(Flex, {
|
|
356
|
+
direction: "column",
|
|
357
|
+
gap: 3,
|
|
358
|
+
onClick: handleLayoutClick,
|
|
359
|
+
padding: 3,
|
|
360
|
+
sizing: "border",
|
|
361
|
+
style: t8,
|
|
362
|
+
children: t16
|
|
363
|
+
}), $[34] = handleLayoutClick, $[35] = t16, $[36] = t8, $[37] = t17) : t17 = $[37];
|
|
364
|
+
let t18;
|
|
365
|
+
$[38] !== t17 || $[39] !== t5 ? (t18 = /* @__PURE__ */ jsx(Card, {
|
|
366
|
+
tone: "inherit",
|
|
367
|
+
"data-collapsed": t5,
|
|
368
|
+
children: t17
|
|
369
|
+
}), $[38] = t17, $[39] = t5, $[40] = t18) : t18 = $[40];
|
|
370
|
+
let t19;
|
|
371
|
+
return $[41] !== props || $[42] !== t18 || $[43] !== t3 || $[44] !== t4 ? (t19 = /* @__PURE__ */ jsx(LayerProvider, {
|
|
372
|
+
zOffset: 100,
|
|
373
|
+
children: /* @__PURE__ */ jsx(Layer, {
|
|
374
|
+
"data-collapsed": t3,
|
|
375
|
+
style: t4,
|
|
376
|
+
...props,
|
|
377
|
+
children: t18
|
|
378
|
+
})
|
|
379
|
+
}), $[41] = props, $[42] = t18, $[43] = t3, $[44] = t4, $[45] = t19) : t19 = $[45], t19;
|
|
380
|
+
}
|
|
381
|
+
function ContentPanel(t0) {
|
|
382
|
+
let $ = c(31), children, description, id, props, title;
|
|
383
|
+
$[0] === t0 ? (children = $[1], description = $[2], id = $[3], props = $[4], title = $[5]) : ({id, title, description, children, ...props} = t0, $[0] = t0, $[1] = children, $[2] = description, $[3] = id, $[4] = props, $[5] = title);
|
|
384
|
+
let { setSidebarExpanded } = useHandbookContext(), paneLayout = useContext(PaneLayoutContext), t1;
|
|
385
|
+
$[6] !== paneLayout?.collapsed || $[7] !== setSidebarExpanded ? (t1 = paneLayout?.collapsed === !0 && /* @__PURE__ */ jsx(Button, {
|
|
386
|
+
"aria-label": "Back",
|
|
387
|
+
icon: ArrowLeftIcon,
|
|
388
|
+
mode: "bleed",
|
|
389
|
+
onClick: () => {
|
|
390
|
+
setSidebarExpanded(!0);
|
|
391
|
+
}
|
|
392
|
+
}), $[6] = paneLayout?.collapsed, $[7] = setSidebarExpanded, $[8] = t1) : t1 = $[8];
|
|
500
393
|
let t2;
|
|
501
|
-
|
|
394
|
+
$[9] !== t1 || $[10] !== title ? (t2 = /* @__PURE__ */ jsx(PaneHeader, {
|
|
395
|
+
title,
|
|
396
|
+
backButton: t1
|
|
397
|
+
}), $[9] = t1, $[10] = title, $[11] = t2) : t2 = $[11];
|
|
398
|
+
let t3 = `panel-${id}`, t4;
|
|
399
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
|
400
|
+
maxWidth: 640,
|
|
401
|
+
boxSizing: "border-box",
|
|
402
|
+
marginInline: "auto",
|
|
403
|
+
paddingInline: 20,
|
|
404
|
+
paddingBlockStart: 32,
|
|
405
|
+
paddingBlockEnd: 220
|
|
406
|
+
}, $[12] = t4) : t4 = $[12];
|
|
407
|
+
let t5;
|
|
408
|
+
$[13] === title ? t5 = $[14] : (t5 = /* @__PURE__ */ jsx(Heading, {
|
|
409
|
+
as: "h2",
|
|
410
|
+
size: 4,
|
|
411
|
+
children: title
|
|
412
|
+
}), $[13] = title, $[14] = t5);
|
|
413
|
+
let t6;
|
|
414
|
+
$[15] === description ? t6 = $[16] : (t6 = isDefined(description) && /* @__PURE__ */ jsx(Text, {
|
|
415
|
+
size: 1,
|
|
416
|
+
muted: !0,
|
|
417
|
+
children: description
|
|
418
|
+
}), $[15] = description, $[16] = t6);
|
|
419
|
+
let t7;
|
|
420
|
+
$[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Stack, {
|
|
421
|
+
marginBottom: 6,
|
|
422
|
+
gap: 5,
|
|
423
|
+
children: [t5, t6]
|
|
424
|
+
}), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
|
|
425
|
+
let t8;
|
|
426
|
+
$[20] !== children || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Box, {
|
|
427
|
+
style: t4,
|
|
428
|
+
children: [t7, children]
|
|
429
|
+
}), $[20] = children, $[21] = t7, $[22] = t8) : t8 = $[22];
|
|
430
|
+
let t9;
|
|
431
|
+
$[23] !== id || $[24] !== props || $[25] !== t3 || $[26] !== t8 ? (t9 = /* @__PURE__ */ jsx(PaneContent, {
|
|
432
|
+
id: t3,
|
|
433
|
+
"aria-labelledby": id,
|
|
434
|
+
overflow: "auto",
|
|
435
|
+
...props,
|
|
436
|
+
children: t8
|
|
437
|
+
}), $[23] = id, $[24] = props, $[25] = t3, $[26] = t8, $[27] = t9) : t9 = $[27];
|
|
438
|
+
let t10;
|
|
439
|
+
return $[28] !== t2 || $[29] !== t9 ? (t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t9] }), $[28] = t2, $[29] = t9, $[30] = t10) : t10 = $[30], t10;
|
|
440
|
+
}
|
|
441
|
+
function FieldHint(t0) {
|
|
442
|
+
let $ = c(32), children, icon, label, onClose, onOpen, open, props;
|
|
443
|
+
$[0] === t0 ? (children = $[1], icon = $[2], label = $[3], onClose = $[4], onOpen = $[5], open = $[6], props = $[7]) : ({label, icon, open, children, onOpen, onClose, ...props} = t0, $[0] = t0, $[1] = children, $[2] = icon, $[3] = label, $[4] = onClose, $[5] = onOpen, $[6] = open, $[7] = props);
|
|
444
|
+
let buttonReference = useRef(null), popoverReference = useRef(null), t1;
|
|
445
|
+
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => [buttonReference.current, popoverReference.current], $[8] = t1) : t1 = $[8], useClickOutsideEvent(open ? onClose : void 0, t1);
|
|
446
|
+
let t2;
|
|
447
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { maxWidth: 280 }, $[9] = t2) : t2 = $[9];
|
|
448
|
+
let t3;
|
|
449
|
+
$[10] === label ? t3 = $[11] : (t3 = /* @__PURE__ */ jsx(Text, {
|
|
450
|
+
size: 1,
|
|
451
|
+
weight: "semibold",
|
|
452
|
+
children: label
|
|
453
|
+
}), $[10] = label, $[11] = t3);
|
|
454
|
+
let t4;
|
|
455
|
+
$[12] === children ? t4 = $[13] : (t4 = /* @__PURE__ */ jsx(Text, {
|
|
456
|
+
size: 1,
|
|
457
|
+
muted: !0,
|
|
458
|
+
children
|
|
459
|
+
}), $[12] = children, $[13] = t4);
|
|
460
|
+
let t5;
|
|
461
|
+
$[14] !== t3 || $[15] !== t4 ? (t5 = /* @__PURE__ */ jsx("div", {
|
|
462
|
+
ref: popoverReference,
|
|
463
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
464
|
+
padding: 3,
|
|
465
|
+
style: t2,
|
|
466
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
467
|
+
gap: 3,
|
|
468
|
+
children: [t3, t4]
|
|
469
|
+
})
|
|
470
|
+
})
|
|
471
|
+
}), $[14] = t3, $[15] = t4, $[16] = t5) : t5 = $[16];
|
|
472
|
+
let t6 = open ? onClose : onOpen, t7;
|
|
473
|
+
$[17] === onOpen ? t7 = $[18] : (t7 = (event) => {
|
|
474
|
+
event.pointerType === "mouse" && onOpen();
|
|
475
|
+
}, $[17] = onOpen, $[18] = t7);
|
|
476
|
+
let t8;
|
|
477
|
+
$[19] === onClose ? t8 = $[20] : (t8 = (event_0) => {
|
|
478
|
+
event_0.pointerType === "mouse" && onClose();
|
|
479
|
+
}, $[19] = onClose, $[20] = t8);
|
|
480
|
+
let t9;
|
|
481
|
+
$[21] !== icon || $[22] !== label || $[23] !== t6 || $[24] !== t7 || $[25] !== t8 ? (t9 = /* @__PURE__ */ jsx(Button, {
|
|
482
|
+
ref: buttonReference,
|
|
483
|
+
"aria-label": label,
|
|
484
|
+
fontSize: 2,
|
|
485
|
+
icon,
|
|
486
|
+
mode: "bleed",
|
|
487
|
+
padding: 1,
|
|
488
|
+
onClick: t6,
|
|
489
|
+
onPointerEnter: t7,
|
|
490
|
+
onPointerLeave: t8
|
|
491
|
+
}), $[21] = icon, $[22] = label, $[23] = t6, $[24] = t7, $[25] = t8, $[26] = t9) : t9 = $[26];
|
|
492
|
+
let t10;
|
|
493
|
+
return $[27] !== open || $[28] !== props || $[29] !== t5 || $[30] !== t9 ? (t10 = /* @__PURE__ */ jsx(Popover, {
|
|
494
|
+
open,
|
|
495
|
+
placement: "top",
|
|
496
|
+
portal: !0,
|
|
497
|
+
radius: 2,
|
|
498
|
+
shadow: 2,
|
|
499
|
+
content: t5,
|
|
500
|
+
...props,
|
|
501
|
+
children: t9
|
|
502
|
+
}), $[27] = open, $[28] = props, $[29] = t5, $[30] = t9, $[31] = t10) : t10 = $[31], t10;
|
|
503
|
+
}
|
|
504
|
+
function InfoIcon(props) {
|
|
505
|
+
let $ = c(5), t0, t1, t2;
|
|
506
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("circle", {
|
|
507
|
+
cx: "12",
|
|
508
|
+
cy: "12",
|
|
509
|
+
r: "10"
|
|
510
|
+
}), t1 = /* @__PURE__ */ jsx("path", { d: "M12 16v-4" }), t2 = /* @__PURE__ */ jsx("path", { d: "M12 8h.01" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
511
|
+
let t3;
|
|
512
|
+
return $[3] === props ? t3 = $[4] : (t3 = /* @__PURE__ */ jsxs("svg", {
|
|
502
513
|
xmlns: "http://www.w3.org/2000/svg",
|
|
503
514
|
width: 24,
|
|
504
515
|
height: 24,
|
|
@@ -509,91 +520,16 @@ function CodeIcon(props) {
|
|
|
509
520
|
strokeLinecap: "round",
|
|
510
521
|
strokeLinejoin: "round",
|
|
511
522
|
...props,
|
|
512
|
-
children: [
|
|
513
|
-
|
|
523
|
+
children: [
|
|
524
|
+
t0,
|
|
525
|
+
t1,
|
|
526
|
+
t2
|
|
527
|
+
]
|
|
528
|
+
}), $[3] = props, $[4] = t3), t3;
|
|
514
529
|
}
|
|
515
|
-
|
|
516
|
-
const codeTypeName = "handbook.code", codeType = defineType({
|
|
517
|
-
name: codeTypeName,
|
|
518
|
-
type: "object",
|
|
519
|
-
title: "Code",
|
|
520
|
-
icon: createSanityIcon(CodeIcon),
|
|
521
|
-
description: "Syntax-highlighted code block with language selection.",
|
|
522
|
-
components: { preview: CodePreview },
|
|
523
|
-
preview: { select: {
|
|
524
|
-
code: "code",
|
|
525
|
-
language: "language"
|
|
526
|
-
} },
|
|
527
|
-
fields: [defineField({
|
|
528
|
-
name: "code",
|
|
529
|
-
type: "text",
|
|
530
|
-
description: "The source code to display."
|
|
531
|
-
}), defineField({
|
|
532
|
-
name: "language",
|
|
533
|
-
type: "string",
|
|
534
|
-
description: "Programming language used for syntax highlighting.",
|
|
535
|
-
options: { list: [
|
|
536
|
-
{
|
|
537
|
-
title: "CSS",
|
|
538
|
-
value: "css"
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
title: "GROQ",
|
|
542
|
-
value: "groq"
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
title: "HTML",
|
|
546
|
-
value: "html"
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
title: "JavaScript",
|
|
550
|
-
value: "javascript"
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
title: "JSON",
|
|
554
|
-
value: "json"
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
title: "Plain Text",
|
|
558
|
-
value: "text"
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
title: "React",
|
|
562
|
-
value: "tsx"
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
title: "Shell",
|
|
566
|
-
value: "shell"
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
title: "TypeScript",
|
|
570
|
-
value: "typescript"
|
|
571
|
-
}
|
|
572
|
-
] }
|
|
573
|
-
})]
|
|
574
|
-
});
|
|
575
|
-
function HorizontalRuleContent(t0) {
|
|
576
|
-
let $ = c(8), props, style;
|
|
577
|
-
$[0] === t0 ? (props = $[1], style = $[2]) : ({style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style);
|
|
578
|
-
let t1;
|
|
579
|
-
$[3] === style ? t1 = $[4] : (t1 = {
|
|
580
|
-
border: "none",
|
|
581
|
-
borderTop: "1px solid var(--card-border-color)",
|
|
582
|
-
...style
|
|
583
|
-
}, $[3] = style, $[4] = t1);
|
|
584
|
-
let t2;
|
|
585
|
-
return $[5] !== props || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsx("hr", {
|
|
586
|
-
style: t1,
|
|
587
|
-
...props
|
|
588
|
-
}), $[5] = props, $[6] = t1, $[7] = t2) : t2 = $[7], t2;
|
|
589
|
-
}
|
|
590
|
-
function HorizontalRulePreview(_props) {
|
|
591
|
-
let $ = c(1), t0;
|
|
592
|
-
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(HorizontalRuleContent, { style: { marginBlock: 8 } }), $[0] = t0) : t0 = $[0], t0;
|
|
593
|
-
}
|
|
594
|
-
function SeparatorHorizontalIcon(props) {
|
|
530
|
+
function LightbulbIcon(props) {
|
|
595
531
|
let $ = c(5), t0, t1, t2;
|
|
596
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "
|
|
532
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" }), t1 = /* @__PURE__ */ jsx("path", { d: "M9 18h6" }), t2 = /* @__PURE__ */ jsx("path", { d: "M10 22h4" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
597
533
|
let t3;
|
|
598
534
|
return $[3] === props ? t3 = $[4] : (t3 = /* @__PURE__ */ jsxs("svg", {
|
|
599
535
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -613,98 +549,9 @@ function SeparatorHorizontalIcon(props) {
|
|
|
613
549
|
]
|
|
614
550
|
}), $[3] = props, $[4] = t3), t3;
|
|
615
551
|
}
|
|
616
|
-
|
|
617
|
-
const horizontalRuleTypeName = "handbook.horizontalRule", horizontalRuleType = defineType({
|
|
618
|
-
name: horizontalRuleTypeName,
|
|
619
|
-
type: "object",
|
|
620
|
-
title: "Horizontal Rule",
|
|
621
|
-
icon: createSanityIcon(SeparatorHorizontalIcon),
|
|
622
|
-
description: "Visual divider between sections of content.",
|
|
623
|
-
components: { preview: HorizontalRulePreview },
|
|
624
|
-
preview: { prepare() {
|
|
625
|
-
return { title: "Horizontal Rule" };
|
|
626
|
-
} },
|
|
627
|
-
fields: [defineField({
|
|
628
|
-
name: "style",
|
|
629
|
-
type: "string",
|
|
630
|
-
description: "Reserved. A horizontal rule carries no authored content.",
|
|
631
|
-
hidden: !0
|
|
632
|
-
})]
|
|
633
|
-
});
|
|
634
|
-
function Caption(t0) {
|
|
635
|
-
let $ = c(13), children, props, style;
|
|
636
|
-
$[0] === t0 ? (children = $[1], props = $[2], style = $[3]) : ({children, style, ...props} = t0, $[0] = t0, $[1] = children, $[2] = props, $[3] = style);
|
|
637
|
-
let t1;
|
|
638
|
-
$[4] === style ? t1 = $[5] : (t1 = {
|
|
639
|
-
marginBlockStart: 12,
|
|
640
|
-
...style
|
|
641
|
-
}, $[4] = style, $[5] = t1);
|
|
642
|
-
let t2;
|
|
643
|
-
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { fontStyle: "italic" }, $[6] = t2) : t2 = $[6];
|
|
644
|
-
let t3;
|
|
645
|
-
$[7] === children ? t3 = $[8] : (t3 = /* @__PURE__ */ jsx(Text, {
|
|
646
|
-
size: 1,
|
|
647
|
-
muted: !0,
|
|
648
|
-
style: t2,
|
|
649
|
-
children
|
|
650
|
-
}), $[7] = children, $[8] = t3);
|
|
651
|
-
let t4;
|
|
652
|
-
return $[9] !== props || $[10] !== t1 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsx("div", {
|
|
653
|
-
style: t1,
|
|
654
|
-
...props,
|
|
655
|
-
children: t3
|
|
656
|
-
}), $[9] = props, $[10] = t1, $[11] = t3, $[12] = t4) : t4 = $[12], t4;
|
|
657
|
-
}
|
|
658
|
-
function ImageContent(t0) {
|
|
659
|
-
let $ = c(15), alt, caption, props, url;
|
|
660
|
-
$[0] === t0 ? (alt = $[1], caption = $[2], props = $[3], url = $[4]) : ({url, alt, caption, ...props} = t0, $[0] = t0, $[1] = alt, $[2] = caption, $[3] = props, $[4] = url);
|
|
661
|
-
let t1 = alt ?? "", t2;
|
|
662
|
-
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
663
|
-
display: "block",
|
|
664
|
-
maxWidth: "100%",
|
|
665
|
-
borderRadius: 4
|
|
666
|
-
}, $[5] = t2) : t2 = $[5];
|
|
667
|
-
let t3;
|
|
668
|
-
$[6] !== t1 || $[7] !== url ? (t3 = /* @__PURE__ */ jsx("img", {
|
|
669
|
-
src: url,
|
|
670
|
-
alt: t1,
|
|
671
|
-
style: t2
|
|
672
|
-
}), $[6] = t1, $[7] = url, $[8] = t3) : t3 = $[8];
|
|
673
|
-
let t4;
|
|
674
|
-
$[9] === caption ? t4 = $[10] : (t4 = isDefined(caption) && /* @__PURE__ */ jsx(Caption, { children: caption }), $[9] = caption, $[10] = t4);
|
|
675
|
-
let t5;
|
|
676
|
-
return $[11] !== props || $[12] !== t3 || $[13] !== t4 ? (t5 = /* @__PURE__ */ jsxs("div", {
|
|
677
|
-
...props,
|
|
678
|
-
children: [t3, t4]
|
|
679
|
-
}), $[11] = props, $[12] = t3, $[13] = t4, $[14] = t5) : t5 = $[14], t5;
|
|
680
|
-
}
|
|
681
|
-
function ImagePreview(t0) {
|
|
682
|
-
let $ = c(5), { url, alt, caption } = t0;
|
|
683
|
-
if (!isDefined(url)) return null;
|
|
684
|
-
let t1;
|
|
685
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = { padding: 8 }, $[0] = t1) : t1 = $[0];
|
|
686
|
-
let t2;
|
|
687
|
-
return $[1] !== alt || $[2] !== caption || $[3] !== url ? (t2 = /* @__PURE__ */ jsx(ImageContent, {
|
|
688
|
-
url,
|
|
689
|
-
alt,
|
|
690
|
-
caption,
|
|
691
|
-
style: t1
|
|
692
|
-
}), $[1] = alt, $[2] = caption, $[3] = url, $[4] = t2) : t2 = $[4], t2;
|
|
693
|
-
}
|
|
694
|
-
function ImageIcon(props) {
|
|
552
|
+
function TriangleAlertIcon(props) {
|
|
695
553
|
let $ = c(5), t0, t1, t2;
|
|
696
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("
|
|
697
|
-
width: "18",
|
|
698
|
-
height: "18",
|
|
699
|
-
x: "3",
|
|
700
|
-
y: "3",
|
|
701
|
-
rx: "2",
|
|
702
|
-
ry: "2"
|
|
703
|
-
}), t1 = /* @__PURE__ */ jsx("circle", {
|
|
704
|
-
cx: "9",
|
|
705
|
-
cy: "9",
|
|
706
|
-
r: "2"
|
|
707
|
-
}), t2 = /* @__PURE__ */ jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
554
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }), t1 = /* @__PURE__ */ jsx("path", { d: "M12 9v4" }), t2 = /* @__PURE__ */ jsx("path", { d: "M12 17h.01" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
708
555
|
let t3;
|
|
709
556
|
return $[3] === props ? t3 = $[4] : (t3 = /* @__PURE__ */ jsxs("svg", {
|
|
710
557
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -724,1018 +571,295 @@ function ImageIcon(props) {
|
|
|
724
571
|
]
|
|
725
572
|
}), $[3] = props, $[4] = t3), t3;
|
|
726
573
|
}
|
|
727
|
-
/**
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
$[
|
|
773
|
-
kind: "captions",
|
|
774
|
-
label: t2
|
|
775
|
-
}), $[5] = t2, $[6] = t3);
|
|
776
|
-
let t4;
|
|
777
|
-
$[7] !== t3 || $[8] !== url ? (t4 = /* @__PURE__ */ jsx("video", {
|
|
778
|
-
src: url,
|
|
779
|
-
controls: !0,
|
|
780
|
-
style: t1,
|
|
781
|
-
children: t3
|
|
782
|
-
}), $[7] = t3, $[8] = url, $[9] = t4) : t4 = $[9];
|
|
574
|
+
/** Hint kinds, in display order. */
|
|
575
|
+
const hintKinds = [
|
|
576
|
+
{
|
|
577
|
+
name: "tip",
|
|
578
|
+
label: "Tip",
|
|
579
|
+
icon: LightbulbIcon
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
name: "info",
|
|
583
|
+
label: "Information",
|
|
584
|
+
icon: InfoIcon
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: "caution",
|
|
588
|
+
label: "Caution",
|
|
589
|
+
icon: TriangleAlertIcon
|
|
590
|
+
}
|
|
591
|
+
];
|
|
592
|
+
function FieldHints(t0) {
|
|
593
|
+
let $ = c(22), caution, info, props, tip;
|
|
594
|
+
$[0] === t0 ? (caution = $[1], info = $[2], props = $[3], tip = $[4]) : ({tip, info, caution, ...props} = t0, $[0] = t0, $[1] = caution, $[2] = info, $[3] = props, $[4] = tip);
|
|
595
|
+
let [openHint, setOpenHint] = useState(void 0), T0, t1, t2, t3, t4;
|
|
596
|
+
if ($[5] !== caution || $[6] !== info || $[7] !== openHint || $[8] !== props || $[9] !== tip) {
|
|
597
|
+
let hints = {
|
|
598
|
+
tip,
|
|
599
|
+
info,
|
|
600
|
+
caution
|
|
601
|
+
}, t5;
|
|
602
|
+
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t5 = function closeHint() {
|
|
603
|
+
setOpenHint(void 0);
|
|
604
|
+
}, $[15] = t5) : t5 = $[15];
|
|
605
|
+
let closeHint = t5;
|
|
606
|
+
T0 = Flex, t1 = "center", t2 = 2, t3 = props, t4 = hintKinds.flatMap((t6) => {
|
|
607
|
+
let { name, label, icon: Icon } = t6, hint = hints[name];
|
|
608
|
+
return isDefined(hint) ? /* @__PURE__ */ jsx(FieldHint, {
|
|
609
|
+
label,
|
|
610
|
+
icon: /* @__PURE__ */ jsx(Icon, { ...defaultIconProps }),
|
|
611
|
+
open: openHint === name,
|
|
612
|
+
onOpen: () => {
|
|
613
|
+
setOpenHint(name);
|
|
614
|
+
},
|
|
615
|
+
onClose: closeHint,
|
|
616
|
+
children: hint
|
|
617
|
+
}, name) : [];
|
|
618
|
+
}), $[5] = caution, $[6] = info, $[7] = openHint, $[8] = props, $[9] = tip, $[10] = T0, $[11] = t1, $[12] = t2, $[13] = t3, $[14] = t4;
|
|
619
|
+
} else T0 = $[10], t1 = $[11], t2 = $[12], t3 = $[13], t4 = $[14];
|
|
783
620
|
let t5;
|
|
784
|
-
$[
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
...
|
|
788
|
-
children:
|
|
789
|
-
}), $[
|
|
621
|
+
return $[16] !== T0 || $[17] !== t1 || $[18] !== t2 || $[19] !== t3 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(T0, {
|
|
622
|
+
align: t1,
|
|
623
|
+
gap: t2,
|
|
624
|
+
...t3,
|
|
625
|
+
children: t4
|
|
626
|
+
}), $[16] = T0, $[17] = t1, $[18] = t2, $[19] = t3, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
|
|
790
627
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
style: t1
|
|
801
|
-
}), $[1] = caption, $[2] = url, $[3] = t2) : t2 = $[3], t2;
|
|
628
|
+
/**
|
|
629
|
+
* Works out a schema type's label: its Handbook title, then its schema title, then its name in title case.
|
|
630
|
+
*
|
|
631
|
+
* @param type - The schema type or field.
|
|
632
|
+
* @returns The label.
|
|
633
|
+
*/
|
|
634
|
+
function resolveTitle(type) {
|
|
635
|
+
let { name, title, handbook } = type;
|
|
636
|
+
return handbook?.title ?? title ?? convertCase(name, "title");
|
|
802
637
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
return $[8] === props ? t8 = $[9] : (t8 = /* @__PURE__ */ jsxs("svg", {
|
|
814
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
815
|
-
width: 24,
|
|
816
|
-
height: 24,
|
|
817
|
-
viewBox: "0 0 24 24",
|
|
818
|
-
fill: "none",
|
|
819
|
-
stroke: "currentColor",
|
|
820
|
-
strokeWidth: 2,
|
|
821
|
-
strokeLinecap: "round",
|
|
822
|
-
strokeLinejoin: "round",
|
|
823
|
-
...props,
|
|
824
|
-
children: [
|
|
825
|
-
t0,
|
|
826
|
-
t1,
|
|
827
|
-
t2,
|
|
828
|
-
t3,
|
|
829
|
-
t4,
|
|
830
|
-
t5,
|
|
831
|
-
t6,
|
|
832
|
-
t7
|
|
833
|
-
]
|
|
834
|
-
}), $[8] = props, $[9] = t8), t8;
|
|
638
|
+
/**
|
|
639
|
+
* Works out a schema type's description, preferring its Handbook description and ignoring non-string
|
|
640
|
+
* schema descriptions.
|
|
641
|
+
*
|
|
642
|
+
* @param type - The schema type or field.
|
|
643
|
+
* @returns The description, or undefined when there isn't one.
|
|
644
|
+
*/
|
|
645
|
+
function resolveDescription(type) {
|
|
646
|
+
let { description, handbook } = type;
|
|
647
|
+
return handbook?.description ?? (typeof description == "string" ? description : void 0);
|
|
835
648
|
}
|
|
836
|
-
/** Type name of the video block. */
|
|
837
|
-
const videoTypeName = "handbook.video", videoType = defineType({
|
|
838
|
-
name: videoTypeName,
|
|
839
|
-
type: "object",
|
|
840
|
-
title: "Video",
|
|
841
|
-
icon: createSanityIcon(FilmIcon),
|
|
842
|
-
description: "Video with an optional caption.",
|
|
843
|
-
components: { preview: VideoPreview },
|
|
844
|
-
preview: { select: {
|
|
845
|
-
caption: "caption",
|
|
846
|
-
url: "asset.asset.url"
|
|
847
|
-
} },
|
|
848
|
-
fields: [defineField({
|
|
849
|
-
name: "asset",
|
|
850
|
-
title: "Video",
|
|
851
|
-
type: "file",
|
|
852
|
-
description: "Upload or select a video from the media library.",
|
|
853
|
-
options: { accept: "video/*" }
|
|
854
|
-
}), defineField({
|
|
855
|
-
name: "caption",
|
|
856
|
-
type: "string",
|
|
857
|
-
description: "Caption text displayed below the video, such as a credit or a note."
|
|
858
|
-
})]
|
|
859
|
-
});
|
|
860
649
|
/**
|
|
861
|
-
*
|
|
862
|
-
*
|
|
650
|
+
* Gets a schema type's icon as a component, redrawn at the plugin's icon size to match the built-in icons.
|
|
651
|
+
* String icons are ignored.
|
|
863
652
|
*
|
|
864
|
-
* @param
|
|
865
|
-
* @returns
|
|
653
|
+
* @param type - The schema type.
|
|
654
|
+
* @returns The icon component, or undefined when there isn't one.
|
|
866
655
|
*/
|
|
867
|
-
function
|
|
868
|
-
return
|
|
869
|
-
name: "content",
|
|
870
|
-
type: "array",
|
|
871
|
-
description: "Rich text with formatting, headings, lists, images, code blocks, and custom blocks.",
|
|
872
|
-
of: [
|
|
873
|
-
defineArrayMember({
|
|
874
|
-
name: "block",
|
|
875
|
-
type: "block",
|
|
876
|
-
styles: [
|
|
877
|
-
{
|
|
878
|
-
title: "Paragraph",
|
|
879
|
-
value: "normal",
|
|
880
|
-
component: ParagraphStyle
|
|
881
|
-
},
|
|
882
|
-
{
|
|
883
|
-
title: "Heading",
|
|
884
|
-
value: "h2",
|
|
885
|
-
component: HeadingStyle
|
|
886
|
-
},
|
|
887
|
-
{
|
|
888
|
-
title: "Blockquote",
|
|
889
|
-
value: "blockquote",
|
|
890
|
-
component: BlockquoteStyle
|
|
891
|
-
}
|
|
892
|
-
],
|
|
893
|
-
lists: [{
|
|
894
|
-
title: "Bullet",
|
|
895
|
-
value: "bullet",
|
|
896
|
-
component: ListItemStyle
|
|
897
|
-
}, {
|
|
898
|
-
title: "Number",
|
|
899
|
-
value: "number",
|
|
900
|
-
component: ListItemStyle
|
|
901
|
-
}],
|
|
902
|
-
marks: {
|
|
903
|
-
decorators: [
|
|
904
|
-
{
|
|
905
|
-
title: "Bold",
|
|
906
|
-
value: "strong"
|
|
907
|
-
},
|
|
908
|
-
{
|
|
909
|
-
title: "Italic",
|
|
910
|
-
value: "em"
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
title: "Strikethrough",
|
|
914
|
-
value: "strike-through"
|
|
915
|
-
},
|
|
916
|
-
{
|
|
917
|
-
title: "Code",
|
|
918
|
-
value: "code",
|
|
919
|
-
component: CodeDecorator
|
|
920
|
-
}
|
|
921
|
-
],
|
|
922
|
-
annotations: [linkAnnotation]
|
|
923
|
-
}
|
|
924
|
-
}),
|
|
925
|
-
defineArrayMember({
|
|
926
|
-
name: imageTypeName,
|
|
927
|
-
type: imageTypeName
|
|
928
|
-
}),
|
|
929
|
-
defineArrayMember({
|
|
930
|
-
name: videoTypeName,
|
|
931
|
-
type: videoTypeName
|
|
932
|
-
}),
|
|
933
|
-
defineArrayMember({
|
|
934
|
-
name: codeTypeName,
|
|
935
|
-
type: codeTypeName
|
|
936
|
-
}),
|
|
937
|
-
defineArrayMember({
|
|
938
|
-
name: calloutTypeName,
|
|
939
|
-
type: calloutTypeName
|
|
940
|
-
}),
|
|
941
|
-
defineArrayMember({
|
|
942
|
-
name: horizontalRuleTypeName,
|
|
943
|
-
type: horizontalRuleTypeName
|
|
944
|
-
}),
|
|
945
|
-
...customBlocks.map((block) => defineArrayMember({
|
|
946
|
-
name: block.schema.name,
|
|
947
|
-
type: block.schema.name
|
|
948
|
-
}))
|
|
949
|
-
]
|
|
950
|
-
});
|
|
656
|
+
function resolveIcon(type) {
|
|
657
|
+
return typeof type.icon == "function" ? createSanityIcon(type.icon) : void 0;
|
|
951
658
|
}
|
|
952
|
-
/**
|
|
953
|
-
const
|
|
659
|
+
/** Types whose subfields aren't shown. */
|
|
660
|
+
const opaqueTypes = /* @__PURE__ */ new Set([
|
|
661
|
+
"block",
|
|
662
|
+
"boolean",
|
|
663
|
+
"crossDatasetReference",
|
|
664
|
+
"date",
|
|
665
|
+
"datetime",
|
|
666
|
+
"file",
|
|
667
|
+
"geopoint",
|
|
668
|
+
"image",
|
|
669
|
+
"number",
|
|
670
|
+
"reference",
|
|
671
|
+
"slug",
|
|
672
|
+
"string",
|
|
673
|
+
"text",
|
|
674
|
+
"url"
|
|
675
|
+
]), inheritedFieldNames = {
|
|
676
|
+
block: /* @__PURE__ */ new Set([
|
|
677
|
+
"children",
|
|
678
|
+
"level",
|
|
679
|
+
"listItem",
|
|
680
|
+
"markDefs",
|
|
681
|
+
"style"
|
|
682
|
+
]),
|
|
683
|
+
file: /* @__PURE__ */ new Set(["asset", "media"]),
|
|
684
|
+
geopoint: /* @__PURE__ */ new Set([
|
|
685
|
+
"alt",
|
|
686
|
+
"lat",
|
|
687
|
+
"lng"
|
|
688
|
+
]),
|
|
689
|
+
image: /* @__PURE__ */ new Set([
|
|
690
|
+
"asset",
|
|
691
|
+
"crop",
|
|
692
|
+
"hotspot",
|
|
693
|
+
"media"
|
|
694
|
+
]),
|
|
695
|
+
slug: /* @__PURE__ */ new Set(["current", "source"])
|
|
696
|
+
};
|
|
954
697
|
/**
|
|
955
|
-
*
|
|
956
|
-
* built-in blocks alongside any a consumer registered.
|
|
698
|
+
* Checks whether a value is a compiled schema field with a type object.
|
|
957
699
|
*
|
|
958
|
-
* @param
|
|
959
|
-
* @returns
|
|
700
|
+
* @param value - The value to check.
|
|
701
|
+
* @returns True if the value is a compiled field.
|
|
960
702
|
*/
|
|
961
|
-
function
|
|
962
|
-
return
|
|
963
|
-
name: guideTypeName,
|
|
964
|
-
type: "document",
|
|
965
|
-
title: "Handbook Guide",
|
|
966
|
-
icon: createSanityIcon(BookOpenTextIcon),
|
|
967
|
-
description: "Handbook page authored with rich text, images, and custom blocks.",
|
|
968
|
-
preview: {
|
|
969
|
-
select: {
|
|
970
|
-
title: "title",
|
|
971
|
-
description: "description"
|
|
972
|
-
},
|
|
973
|
-
prepare(selection) {
|
|
974
|
-
let { title, description } = selection;
|
|
975
|
-
return {
|
|
976
|
-
title: title ?? "Untitled",
|
|
977
|
-
subtitle: description
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
},
|
|
981
|
-
fields: [
|
|
982
|
-
defineField({
|
|
983
|
-
name: "title",
|
|
984
|
-
type: "string",
|
|
985
|
-
description: "Appears in the Handbook sidebar and as the guide heading.",
|
|
986
|
-
validation: (rule) => rule.required()
|
|
987
|
-
}),
|
|
988
|
-
defineField({
|
|
989
|
-
name: "description",
|
|
990
|
-
type: "string",
|
|
991
|
-
description: "Short introduction text displayed below the guide heading."
|
|
992
|
-
}),
|
|
993
|
-
createGuideContentField(customBlocks)
|
|
994
|
-
]
|
|
995
|
-
});
|
|
703
|
+
function isCompiledField(value) {
|
|
704
|
+
return !isRecord(value) || !("name" in value) || !("type" in value) ? !1 : isRecord(value.type);
|
|
996
705
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
viewBox: "0 0 24 24",
|
|
1006
|
-
fill: "none",
|
|
1007
|
-
stroke: "currentColor",
|
|
1008
|
-
strokeWidth: 2,
|
|
1009
|
-
strokeLinecap: "round",
|
|
1010
|
-
strokeLinejoin: "round",
|
|
1011
|
-
...props,
|
|
1012
|
-
children: [
|
|
1013
|
-
t0,
|
|
1014
|
-
t1,
|
|
1015
|
-
t2
|
|
1016
|
-
]
|
|
1017
|
-
}), $[3] = props, $[4] = t3), t3;
|
|
706
|
+
/**
|
|
707
|
+
* Checks whether a value has a `fields` array.
|
|
708
|
+
*
|
|
709
|
+
* @param value - The value to check.
|
|
710
|
+
* @returns True if the value has a `fields` array.
|
|
711
|
+
*/
|
|
712
|
+
function hasFieldsArray(value) {
|
|
713
|
+
return isRecord(value) && Array.isArray(value.fields);
|
|
1018
714
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
viewBox: "0 0 24 24",
|
|
1028
|
-
fill: "none",
|
|
1029
|
-
stroke: "currentColor",
|
|
1030
|
-
strokeWidth: 2,
|
|
1031
|
-
strokeLinecap: "round",
|
|
1032
|
-
strokeLinejoin: "round",
|
|
1033
|
-
...props,
|
|
1034
|
-
children: [
|
|
1035
|
-
t0,
|
|
1036
|
-
t1,
|
|
1037
|
-
t2,
|
|
1038
|
-
t3,
|
|
1039
|
-
t4
|
|
1040
|
-
]
|
|
1041
|
-
}), $[5] = props, $[6] = t5), t5;
|
|
715
|
+
/**
|
|
716
|
+
* Checks whether a value has an `of` array.
|
|
717
|
+
*
|
|
718
|
+
* @param value - The value to check.
|
|
719
|
+
* @returns True if the value has an `of` array.
|
|
720
|
+
*/
|
|
721
|
+
function hasOfArray(value) {
|
|
722
|
+
return isRecord(value) && Array.isArray(value.of);
|
|
1042
723
|
}
|
|
1043
|
-
/** Document type name of the Handbook singleton. */
|
|
1044
|
-
const handbookTypeName = "handbook.handbook", handbookType = defineType({
|
|
1045
|
-
name: handbookTypeName,
|
|
1046
|
-
type: "document",
|
|
1047
|
-
title: "Handbook",
|
|
1048
|
-
icon: createSanityIcon(BookTextIcon),
|
|
1049
|
-
description: "Defines the groups of guides shown in the Handbook sidebar, and the order they appear in.",
|
|
1050
|
-
preview: { prepare() {
|
|
1051
|
-
return { title: "Handbook" };
|
|
1052
|
-
} },
|
|
1053
|
-
fields: [defineField({
|
|
1054
|
-
name: "groups",
|
|
1055
|
-
type: "array",
|
|
1056
|
-
description: "Ordered list of groups displayed in the Handbook sidebar. Each group contains a title and an ordered list of guide references.",
|
|
1057
|
-
of: [defineArrayMember({
|
|
1058
|
-
name: "group",
|
|
1059
|
-
type: "object",
|
|
1060
|
-
icon: createSanityIcon(ListPlusIcon),
|
|
1061
|
-
description: "Named section of the Handbook sidebar holding an ordered list of guides.",
|
|
1062
|
-
fields: [defineField({
|
|
1063
|
-
name: "title",
|
|
1064
|
-
type: "string",
|
|
1065
|
-
description: "Heading displayed above this group of guides in the sidebar.",
|
|
1066
|
-
validation: (rule) => rule.required()
|
|
1067
|
-
}), defineField({
|
|
1068
|
-
name: "guides",
|
|
1069
|
-
type: "array",
|
|
1070
|
-
description: "Ordered list of guides within this group. Drag to reorder.",
|
|
1071
|
-
of: [defineArrayMember({
|
|
1072
|
-
name: "guide",
|
|
1073
|
-
type: "reference",
|
|
1074
|
-
to: [{ type: guideTypeName }]
|
|
1075
|
-
})]
|
|
1076
|
-
})],
|
|
1077
|
-
preview: {
|
|
1078
|
-
select: {
|
|
1079
|
-
title: "title",
|
|
1080
|
-
guide0: "guides.0.title",
|
|
1081
|
-
guide1: "guides.1.title",
|
|
1082
|
-
guide2: "guides.2.title"
|
|
1083
|
-
},
|
|
1084
|
-
prepare(selection) {
|
|
1085
|
-
let { title, guide0, guide1, guide2 } = selection, shown = [
|
|
1086
|
-
guide0,
|
|
1087
|
-
guide1,
|
|
1088
|
-
guide2
|
|
1089
|
-
].filter((guide) => isDefined(guide)).slice(0, 2), hasMore = isDefined(guide2);
|
|
1090
|
-
function formatSubtitle() {
|
|
1091
|
-
return isDefined(shown) ? hasMore ? `${shown.join(", ")}, and others` : shown.join(" and ") : "No guides selected";
|
|
1092
|
-
}
|
|
1093
|
-
return {
|
|
1094
|
-
title: title ?? "Group",
|
|
1095
|
-
subtitle: formatSubtitle()
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
})]
|
|
1100
|
-
})]
|
|
1101
|
-
}), singletonTypes = /* @__PURE__ */ new Set([handbookTypeName]), documentTypes = /* @__PURE__ */ new Set([handbookTypeName, guideTypeName]), contentSpacing = {
|
|
1102
|
-
section: 48,
|
|
1103
|
-
paragraph: 16,
|
|
1104
|
-
heading: 48,
|
|
1105
|
-
media: 24,
|
|
1106
|
-
callout: 32,
|
|
1107
|
-
blockquote: 32,
|
|
1108
|
-
list: 32,
|
|
1109
|
-
nestedList: 12,
|
|
1110
|
-
rule: 40
|
|
1111
|
-
}, assetUrlFragment = "\"asset\": { \"url\": asset.asset->url }", guideFragment = `...@-> {
|
|
1112
|
-
...,
|
|
1113
|
-
content[] { ..., ${`
|
|
1114
|
-
_type == "${imageTypeName}" => { ..., ${assetUrlFragment} },
|
|
1115
|
-
_type == "${videoTypeName}" => { ..., ${assetUrlFragment} }
|
|
1116
|
-
`} }
|
|
1117
|
-
}`;
|
|
1118
724
|
/**
|
|
1119
|
-
*
|
|
1120
|
-
* instead of being told it at every call site.
|
|
725
|
+
* Reads the type name a value declares.
|
|
1121
726
|
*
|
|
1122
|
-
* @param
|
|
1123
|
-
* @returns The
|
|
727
|
+
* @param value - The value.
|
|
728
|
+
* @returns The type name, or undefined when there isn't one.
|
|
1124
729
|
*/
|
|
1125
|
-
function
|
|
1126
|
-
|
|
730
|
+
function getTypeName(value) {
|
|
731
|
+
let typeName = readPath(value, ["type"]);
|
|
732
|
+
return typeof typeName == "string" ? typeName : void 0;
|
|
1127
733
|
}
|
|
1128
734
|
/**
|
|
1129
|
-
*
|
|
735
|
+
* Reads the parent type name from a compiled schema type.
|
|
1130
736
|
*
|
|
1131
|
-
* @param
|
|
1132
|
-
* @
|
|
1133
|
-
* @returns The result, or undefined when the query matched nothing.
|
|
737
|
+
* @param resolvedType - The compiled schema type.
|
|
738
|
+
* @returns The parent type name, or undefined when there isn't one.
|
|
1134
739
|
*/
|
|
1135
|
-
|
|
1136
|
-
|
|
740
|
+
function getParentTypeName(resolvedType) {
|
|
741
|
+
let parentName = readPath(resolvedType, ["type", "name"]);
|
|
742
|
+
return isDefined(parentName) ? String(parentName) : void 0;
|
|
1137
743
|
}
|
|
1138
|
-
/** Fetches the Handbook singleton with expanded guide references. */
|
|
1139
|
-
const handbookQuery = defineTypedQuery(`
|
|
1140
|
-
*[_type == "${handbookTypeName}"][0] {
|
|
1141
|
-
...,
|
|
1142
|
-
groups[] {
|
|
1143
|
-
...,
|
|
1144
|
-
guides[] {
|
|
1145
|
-
...,
|
|
1146
|
-
${guideFragment}
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
`), handbookDocumentsQuery = defineTypedQuery(`*[_type == "${handbookTypeName}" || _type == "${guideTypeName}"]`);
|
|
1151
744
|
/**
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
745
|
+
* Converts a compiled schema field into the shape the Handbook renders. Types already seen are tracked,
|
|
746
|
+
* so a type that refers to itself doesn't recurse forever.
|
|
1154
747
|
*
|
|
1155
|
-
* @
|
|
748
|
+
* @param field - A compiled field or a plain field definition.
|
|
749
|
+
* @param visited - Type names already seen.
|
|
750
|
+
* @returns The normalised field.
|
|
1156
751
|
*/
|
|
1157
|
-
function
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
fetchHandbook();
|
|
1166
|
-
let subscription = client.listen(handbookDocumentsQuery).subscribe(() => {
|
|
1167
|
-
fetchHandbook();
|
|
1168
|
-
});
|
|
1169
|
-
return () => {
|
|
1170
|
-
subscription.unsubscribe();
|
|
752
|
+
function normalizeField(field, visited = /* @__PURE__ */ new Set()) {
|
|
753
|
+
if (isCompiledField(field)) {
|
|
754
|
+
let typeName = field.type.name, result = {
|
|
755
|
+
name: field.name,
|
|
756
|
+
type: typeName,
|
|
757
|
+
title: field.title ?? field.type.title,
|
|
758
|
+
description: field.description ?? field.type.description,
|
|
759
|
+
handbook: field.handbook
|
|
1171
760
|
};
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
}
|
|
761
|
+
if (!visited.has(typeName)) {
|
|
762
|
+
let next = !opaqueTypes.has(typeName) && typeName !== "object" && typeName !== "array" ? /* @__PURE__ */ new Set([...visited, typeName]) : visited, fieldSource = hasFieldsArray(field) ? field : field.type, ofSource = hasOfArray(field) ? field : field.type;
|
|
763
|
+
hasFieldsArray(fieldSource) && (result.fields = fieldSource.fields.map((subfield) => normalizeField(subfield, next))), hasOfArray(ofSource) && (result.of = ofSource.of.map((member) => normalizeField(member, next)));
|
|
764
|
+
}
|
|
765
|
+
return result;
|
|
766
|
+
}
|
|
767
|
+
return field;
|
|
1178
768
|
}
|
|
1179
|
-
const HandbookContext = createContext(void 0);
|
|
1180
769
|
/**
|
|
1181
|
-
*
|
|
770
|
+
* Lists the fields a custom type adds to an opaque base type, leaving out the base type's own.
|
|
1182
771
|
*
|
|
1183
|
-
* @
|
|
1184
|
-
* @
|
|
772
|
+
* @param resolvedType - The compiled or normalised schema type.
|
|
773
|
+
* @param parentName - The opaque base type's name.
|
|
774
|
+
* @returns The custom fields, or undefined when there are none.
|
|
1185
775
|
*/
|
|
1186
|
-
function
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
return
|
|
776
|
+
function resolveCustomFields(resolvedType, parentName) {
|
|
777
|
+
if (!hasFieldsArray(resolvedType)) return;
|
|
778
|
+
let inherited = inheritedFieldNames[parentName], customFields = resolvedType.fields.map((field) => normalizeField(field)).filter((field) => !isDefined(inherited) || !inherited.has(field.name));
|
|
779
|
+
return isDefined(customFields) ? customFields : void 0;
|
|
1190
780
|
}
|
|
1191
781
|
/**
|
|
1192
|
-
*
|
|
1193
|
-
* the handbook singleton fetched from the dataset.
|
|
782
|
+
* Normalises a list of raw fields.
|
|
1194
783
|
*
|
|
1195
|
-
* @param
|
|
1196
|
-
* @returns The
|
|
784
|
+
* @param items - The raw fields.
|
|
785
|
+
* @returns The normalised fields, or undefined when there are none.
|
|
1197
786
|
*/
|
|
1198
|
-
function
|
|
1199
|
-
let
|
|
1200
|
-
|
|
1201
|
-
sidebarTitle,
|
|
1202
|
-
roles,
|
|
1203
|
-
blocks,
|
|
1204
|
-
undocumentedFieldMessage,
|
|
1205
|
-
activeTab,
|
|
1206
|
-
sidebarExpanded,
|
|
1207
|
-
loading,
|
|
1208
|
-
handbook,
|
|
1209
|
-
setActiveTab,
|
|
1210
|
-
setSidebarExpanded
|
|
1211
|
-
}, $[0] = activeTab, $[1] = blocks, $[2] = handbook, $[3] = loading, $[4] = roles, $[5] = sidebarExpanded, $[6] = sidebarTitle, $[7] = undocumentedFieldMessage, $[8] = t1) : t1 = $[8];
|
|
1212
|
-
let t2;
|
|
1213
|
-
return $[9] !== children || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(HandbookContext, {
|
|
1214
|
-
value: t1,
|
|
1215
|
-
children
|
|
1216
|
-
}), $[9] = children, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
|
|
787
|
+
function resolveNormalizedFields(items) {
|
|
788
|
+
let normalized = items.map((item) => normalizeField(item));
|
|
789
|
+
return isDefined(normalized) ? normalized : void 0;
|
|
1217
790
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
let
|
|
1226
|
-
|
|
1227
|
-
collapsed && pane?.expand();
|
|
1228
|
-
}, $[8] = collapsed, $[9] = pane, $[10] = t2) : t2 = $[10];
|
|
1229
|
-
let handleLayoutClick = t2, t3 = collapsed ? "" : void 0, t4;
|
|
1230
|
-
$[11] === style ? t4 = $[12] : (t4 = {
|
|
1231
|
-
lineHeight: 0,
|
|
1232
|
-
position: "sticky",
|
|
1233
|
-
top: 0,
|
|
1234
|
-
...style
|
|
1235
|
-
}, $[11] = style, $[12] = t4);
|
|
1236
|
-
let t5 = collapsed ? "" : void 0, t6 = collapsed ? collapsedWidth : void 0, t7 = collapsed ? "rotate(90deg)" : void 0, t8;
|
|
1237
|
-
$[13] !== t6 || $[14] !== t7 ? (t8 = {
|
|
1238
|
-
width: t6,
|
|
1239
|
-
transform: t7,
|
|
1240
|
-
transformOrigin: "calc(51px / 2)"
|
|
1241
|
-
}, $[13] = t6, $[14] = t7, $[15] = t8) : t8 = $[15];
|
|
1242
|
-
let t9;
|
|
1243
|
-
$[16] === backButton ? t9 = $[17] : (t9 = isDefined(backButton) && /* @__PURE__ */ jsx(Box, {
|
|
1244
|
-
flex: "none",
|
|
1245
|
-
children: backButton
|
|
1246
|
-
}), $[16] = backButton, $[17] = t9);
|
|
1247
|
-
let t10 = isDefined(backButton) ? 1 : 2, t11 = isLast && !collapsed ? -1 : 0, t12;
|
|
1248
|
-
$[18] === bg ? t12 = $[19] : (t12 = {
|
|
1249
|
-
backgroundColor: bg,
|
|
1250
|
-
minWidth: 0
|
|
1251
|
-
}, $[18] = bg, $[19] = t12);
|
|
1252
|
-
let t13;
|
|
1253
|
-
$[20] === fg ? t13 = $[21] : (t13 = {
|
|
1254
|
-
color: fg,
|
|
1255
|
-
cursor: "default",
|
|
1256
|
-
minWidth: 0,
|
|
1257
|
-
outline: "none"
|
|
1258
|
-
}, $[20] = fg, $[21] = t13);
|
|
1259
|
-
let t14;
|
|
1260
|
-
$[22] !== t13 || $[23] !== title ? (t14 = /* @__PURE__ */ jsx(Flex, {
|
|
1261
|
-
align: "center",
|
|
1262
|
-
gap: 1,
|
|
1263
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
1264
|
-
size: 1,
|
|
1265
|
-
textOverflow: "ellipsis",
|
|
1266
|
-
weight: "semibold",
|
|
1267
|
-
style: t13,
|
|
1268
|
-
children: title
|
|
1269
|
-
})
|
|
1270
|
-
}), $[22] = t13, $[23] = title, $[24] = t14) : t14 = $[24];
|
|
1271
|
-
let t15;
|
|
1272
|
-
$[25] !== handleTitleClick || $[26] !== t10 || $[27] !== t11 || $[28] !== t12 || $[29] !== t14 ? (t15 = /* @__PURE__ */ jsx(Card, {
|
|
1273
|
-
flex: 1,
|
|
1274
|
-
onClick: handleTitleClick,
|
|
1275
|
-
padding: 2,
|
|
1276
|
-
paddingLeft: t10,
|
|
1277
|
-
tabIndex: t11,
|
|
1278
|
-
style: t12,
|
|
1279
|
-
__unstable_focusRing: !0,
|
|
1280
|
-
children: t14
|
|
1281
|
-
}), $[25] = handleTitleClick, $[26] = t10, $[27] = t11, $[28] = t12, $[29] = t14, $[30] = t15) : t15 = $[30];
|
|
1282
|
-
let t16;
|
|
1283
|
-
$[31] !== t15 || $[32] !== t9 ? (t16 = /* @__PURE__ */ jsxs(Flex, {
|
|
1284
|
-
align: "flex-start",
|
|
1285
|
-
gap: 3,
|
|
1286
|
-
children: [t9, t15]
|
|
1287
|
-
}), $[31] = t15, $[32] = t9, $[33] = t16) : t16 = $[33];
|
|
1288
|
-
let t17;
|
|
1289
|
-
$[34] !== handleLayoutClick || $[35] !== t16 || $[36] !== t8 ? (t17 = /* @__PURE__ */ jsx(Flex, {
|
|
1290
|
-
direction: "column",
|
|
1291
|
-
gap: 3,
|
|
1292
|
-
onClick: handleLayoutClick,
|
|
1293
|
-
padding: 3,
|
|
1294
|
-
sizing: "border",
|
|
1295
|
-
style: t8,
|
|
1296
|
-
children: t16
|
|
1297
|
-
}), $[34] = handleLayoutClick, $[35] = t16, $[36] = t8, $[37] = t17) : t17 = $[37];
|
|
1298
|
-
let t18;
|
|
1299
|
-
$[38] !== t17 || $[39] !== t5 ? (t18 = /* @__PURE__ */ jsx(Card, {
|
|
1300
|
-
tone: "inherit",
|
|
1301
|
-
"data-collapsed": t5,
|
|
1302
|
-
children: t17
|
|
1303
|
-
}), $[38] = t17, $[39] = t5, $[40] = t18) : t18 = $[40];
|
|
1304
|
-
let t19;
|
|
1305
|
-
return $[41] !== props || $[42] !== t18 || $[43] !== t3 || $[44] !== t4 ? (t19 = /* @__PURE__ */ jsx(LayerProvider, {
|
|
1306
|
-
zOffset: 100,
|
|
1307
|
-
children: /* @__PURE__ */ jsx(Layer, {
|
|
1308
|
-
"data-collapsed": t3,
|
|
1309
|
-
style: t4,
|
|
1310
|
-
...props,
|
|
1311
|
-
children: t18
|
|
1312
|
-
})
|
|
1313
|
-
}), $[41] = props, $[42] = t18, $[43] = t3, $[44] = t4, $[45] = t19) : t19 = $[45], t19;
|
|
1314
|
-
}
|
|
1315
|
-
function ContentPanel(t0) {
|
|
1316
|
-
let $ = c(31), children, description, id, props, title;
|
|
1317
|
-
$[0] === t0 ? (children = $[1], description = $[2], id = $[3], props = $[4], title = $[5]) : ({id, title, description, children, ...props} = t0, $[0] = t0, $[1] = children, $[2] = description, $[3] = id, $[4] = props, $[5] = title);
|
|
1318
|
-
let { setSidebarExpanded } = useHandbookContext(), paneLayout = useContext(PaneLayoutContext), t1;
|
|
1319
|
-
$[6] !== paneLayout?.collapsed || $[7] !== setSidebarExpanded ? (t1 = paneLayout?.collapsed === !0 && /* @__PURE__ */ jsx(Button, {
|
|
1320
|
-
"aria-label": "Back",
|
|
1321
|
-
icon: ArrowLeftIcon,
|
|
1322
|
-
mode: "bleed",
|
|
1323
|
-
onClick: () => {
|
|
1324
|
-
setSidebarExpanded(!0);
|
|
1325
|
-
}
|
|
1326
|
-
}), $[6] = paneLayout?.collapsed, $[7] = setSidebarExpanded, $[8] = t1) : t1 = $[8];
|
|
1327
|
-
let t2;
|
|
1328
|
-
$[9] !== t1 || $[10] !== title ? (t2 = /* @__PURE__ */ jsx(PaneHeader, {
|
|
1329
|
-
title,
|
|
1330
|
-
backButton: t1
|
|
1331
|
-
}), $[9] = t1, $[10] = title, $[11] = t2) : t2 = $[11];
|
|
1332
|
-
let t3 = `panel-${id}`, t4;
|
|
1333
|
-
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
|
1334
|
-
maxWidth: 640,
|
|
1335
|
-
boxSizing: "border-box",
|
|
1336
|
-
marginInline: "auto",
|
|
1337
|
-
paddingInline: 20,
|
|
1338
|
-
paddingBlockStart: 32,
|
|
1339
|
-
paddingBlockEnd: 220
|
|
1340
|
-
}, $[12] = t4) : t4 = $[12];
|
|
1341
|
-
let t5;
|
|
1342
|
-
$[13] === title ? t5 = $[14] : (t5 = /* @__PURE__ */ jsx(Heading, {
|
|
1343
|
-
as: "h2",
|
|
1344
|
-
size: 4,
|
|
1345
|
-
children: title
|
|
1346
|
-
}), $[13] = title, $[14] = t5);
|
|
1347
|
-
let t6;
|
|
1348
|
-
$[15] === description ? t6 = $[16] : (t6 = isDefined(description) && /* @__PURE__ */ jsx(Text, {
|
|
1349
|
-
size: 1,
|
|
1350
|
-
muted: !0,
|
|
1351
|
-
children: description
|
|
1352
|
-
}), $[15] = description, $[16] = t6);
|
|
1353
|
-
let t7;
|
|
1354
|
-
$[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Stack, {
|
|
1355
|
-
marginBottom: 6,
|
|
1356
|
-
gap: 5,
|
|
1357
|
-
children: [t5, t6]
|
|
1358
|
-
}), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
|
|
1359
|
-
let t8;
|
|
1360
|
-
$[20] !== children || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Box, {
|
|
1361
|
-
style: t4,
|
|
1362
|
-
children: [t7, children]
|
|
1363
|
-
}), $[20] = children, $[21] = t7, $[22] = t8) : t8 = $[22];
|
|
1364
|
-
let t9;
|
|
1365
|
-
$[23] !== id || $[24] !== props || $[25] !== t3 || $[26] !== t8 ? (t9 = /* @__PURE__ */ jsx(PaneContent, {
|
|
1366
|
-
id: t3,
|
|
1367
|
-
"aria-labelledby": id,
|
|
1368
|
-
overflow: "auto",
|
|
1369
|
-
...props,
|
|
1370
|
-
children: t8
|
|
1371
|
-
}), $[23] = id, $[24] = props, $[25] = t3, $[26] = t8, $[27] = t9) : t9 = $[27];
|
|
1372
|
-
let t10;
|
|
1373
|
-
return $[28] !== t2 || $[29] !== t9 ? (t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t9] }), $[28] = t2, $[29] = t9, $[30] = t10) : t10 = $[30], t10;
|
|
1374
|
-
}
|
|
1375
|
-
function FieldHint(t0) {
|
|
1376
|
-
let $ = c(33), children, icon, label, onClose, onOpen, open, props;
|
|
1377
|
-
$[0] === t0 ? (children = $[1], icon = $[2], label = $[3], onClose = $[4], onOpen = $[5], open = $[6], props = $[7]) : ({label, icon, open, children, onOpen, onClose, ...props} = t0, $[0] = t0, $[1] = children, $[2] = icon, $[3] = label, $[4] = onClose, $[5] = onOpen, $[6] = open, $[7] = props);
|
|
1378
|
-
let buttonReference = useRef(null), popoverReference = useRef(null), t1;
|
|
1379
|
-
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => [buttonReference.current, popoverReference.current], $[8] = t1) : t1 = $[8], useClickOutsideEvent(open ? onClose : void 0, t1);
|
|
1380
|
-
let t2;
|
|
1381
|
-
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { maxWidth: 280 }, $[9] = t2) : t2 = $[9];
|
|
1382
|
-
let t3;
|
|
1383
|
-
$[10] === label ? t3 = $[11] : (t3 = /* @__PURE__ */ jsx(Text, {
|
|
1384
|
-
size: 1,
|
|
1385
|
-
weight: "semibold",
|
|
1386
|
-
children: label
|
|
1387
|
-
}), $[10] = label, $[11] = t3);
|
|
1388
|
-
let t4;
|
|
1389
|
-
$[12] === children ? t4 = $[13] : (t4 = /* @__PURE__ */ jsx(Text, {
|
|
1390
|
-
size: 1,
|
|
1391
|
-
muted: !0,
|
|
1392
|
-
children
|
|
1393
|
-
}), $[12] = children, $[13] = t4);
|
|
1394
|
-
let t5;
|
|
1395
|
-
$[14] !== t3 || $[15] !== t4 ? (t5 = /* @__PURE__ */ jsx("div", {
|
|
1396
|
-
ref: popoverReference,
|
|
1397
|
-
children: /* @__PURE__ */ jsx(Box, {
|
|
1398
|
-
padding: 3,
|
|
1399
|
-
style: t2,
|
|
1400
|
-
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1401
|
-
gap: 3,
|
|
1402
|
-
children: [t3, t4]
|
|
1403
|
-
})
|
|
1404
|
-
})
|
|
1405
|
-
}), $[14] = t3, $[15] = t4, $[16] = t5) : t5 = $[16];
|
|
1406
|
-
let t6 = open ? onClose : onOpen, t7;
|
|
1407
|
-
$[17] === onOpen ? t7 = $[18] : (t7 = (event) => {
|
|
1408
|
-
event.pointerType === "mouse" && onOpen();
|
|
1409
|
-
}, $[17] = onOpen, $[18] = t7);
|
|
1410
|
-
let t8;
|
|
1411
|
-
$[19] === onClose ? t8 = $[20] : (t8 = (event_0) => {
|
|
1412
|
-
event_0.pointerType === "mouse" && onClose();
|
|
1413
|
-
}, $[19] = onClose, $[20] = t8);
|
|
1414
|
-
let t9;
|
|
1415
|
-
$[21] === Symbol.for("react.memo_cache_sentinel") ? (t9 = {
|
|
1416
|
-
display: "flex",
|
|
1417
|
-
alignItems: "center",
|
|
1418
|
-
padding: 2,
|
|
1419
|
-
fontSize: 16,
|
|
1420
|
-
color: "var(--card-icon-color)",
|
|
1421
|
-
background: "none",
|
|
1422
|
-
border: "none",
|
|
1423
|
-
cursor: "pointer"
|
|
1424
|
-
}, $[21] = t9) : t9 = $[21];
|
|
1425
|
-
let t10;
|
|
1426
|
-
$[22] !== icon || $[23] !== label || $[24] !== t6 || $[25] !== t7 || $[26] !== t8 ? (t10 = /* @__PURE__ */ jsx("button", {
|
|
1427
|
-
ref: buttonReference,
|
|
1428
|
-
"aria-label": label,
|
|
1429
|
-
type: "button",
|
|
1430
|
-
onClick: t6,
|
|
1431
|
-
onPointerEnter: t7,
|
|
1432
|
-
onPointerLeave: t8,
|
|
1433
|
-
style: t9,
|
|
1434
|
-
children: icon
|
|
1435
|
-
}), $[22] = icon, $[23] = label, $[24] = t6, $[25] = t7, $[26] = t8, $[27] = t10) : t10 = $[27];
|
|
1436
|
-
let t11;
|
|
1437
|
-
return $[28] !== open || $[29] !== props || $[30] !== t10 || $[31] !== t5 ? (t11 = /* @__PURE__ */ jsx(Popover, {
|
|
1438
|
-
open,
|
|
1439
|
-
placement: "top",
|
|
1440
|
-
portal: !0,
|
|
1441
|
-
radius: 2,
|
|
1442
|
-
shadow: 2,
|
|
1443
|
-
content: t5,
|
|
1444
|
-
...props,
|
|
1445
|
-
children: t10
|
|
1446
|
-
}), $[28] = open, $[29] = props, $[30] = t10, $[31] = t5, $[32] = t11) : t11 = $[32], t11;
|
|
1447
|
-
}
|
|
1448
|
-
/** Hint kinds a field can carry, in the order they are displayed. */
|
|
1449
|
-
const hintKinds = [
|
|
1450
|
-
{
|
|
1451
|
-
name: "tip",
|
|
1452
|
-
label: "Tip",
|
|
1453
|
-
icon: LightbulbIcon
|
|
1454
|
-
},
|
|
1455
|
-
{
|
|
1456
|
-
name: "info",
|
|
1457
|
-
label: "Information",
|
|
1458
|
-
icon: InfoIcon
|
|
1459
|
-
},
|
|
1460
|
-
{
|
|
1461
|
-
name: "caution",
|
|
1462
|
-
label: "Caution",
|
|
1463
|
-
icon: TriangleAlertIcon
|
|
1464
|
-
}
|
|
1465
|
-
];
|
|
1466
|
-
function FieldHints(t0) {
|
|
1467
|
-
let $ = c(22), caution, info, props, tip;
|
|
1468
|
-
$[0] === t0 ? (caution = $[1], info = $[2], props = $[3], tip = $[4]) : ({tip, info, caution, ...props} = t0, $[0] = t0, $[1] = caution, $[2] = info, $[3] = props, $[4] = tip);
|
|
1469
|
-
let [openHint, setOpenHint] = useState(void 0), T0, t1, t2, t3, t4;
|
|
1470
|
-
if ($[5] !== caution || $[6] !== info || $[7] !== openHint || $[8] !== props || $[9] !== tip) {
|
|
1471
|
-
let hints = {
|
|
1472
|
-
tip,
|
|
1473
|
-
info,
|
|
1474
|
-
caution
|
|
1475
|
-
}, t5;
|
|
1476
|
-
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t5 = function closeHint() {
|
|
1477
|
-
setOpenHint(void 0);
|
|
1478
|
-
}, $[15] = t5) : t5 = $[15];
|
|
1479
|
-
let closeHint = t5;
|
|
1480
|
-
T0 = Flex, t1 = "center", t2 = 2, t3 = props, t4 = hintKinds.flatMap((t6) => {
|
|
1481
|
-
let { name, label, icon: Icon } = t6, hint = hints[name];
|
|
1482
|
-
return isDefined(hint) ? /* @__PURE__ */ jsx(FieldHint, {
|
|
1483
|
-
label,
|
|
1484
|
-
icon: /* @__PURE__ */ jsx(Icon, { ...defaultIconProps }),
|
|
1485
|
-
open: openHint === name,
|
|
1486
|
-
onOpen: () => {
|
|
1487
|
-
setOpenHint(name);
|
|
1488
|
-
},
|
|
1489
|
-
onClose: closeHint,
|
|
1490
|
-
children: hint
|
|
1491
|
-
}, name) : [];
|
|
1492
|
-
}), $[5] = caution, $[6] = info, $[7] = openHint, $[8] = props, $[9] = tip, $[10] = T0, $[11] = t1, $[12] = t2, $[13] = t3, $[14] = t4;
|
|
1493
|
-
} else T0 = $[10], t1 = $[11], t2 = $[12], t3 = $[13], t4 = $[14];
|
|
1494
|
-
let t5;
|
|
1495
|
-
return $[16] !== T0 || $[17] !== t1 || $[18] !== t2 || $[19] !== t3 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(T0, {
|
|
1496
|
-
align: t1,
|
|
1497
|
-
gap: t2,
|
|
1498
|
-
...t3,
|
|
1499
|
-
children: t4
|
|
1500
|
-
}), $[16] = T0, $[17] = t1, $[18] = t2, $[19] = t3, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
|
|
791
|
+
/**
|
|
792
|
+
* Normalises array members, leaving out opaque types.
|
|
793
|
+
*
|
|
794
|
+
* @param members - The raw array members.
|
|
795
|
+
* @returns The normalised members, or undefined when there are none.
|
|
796
|
+
*/
|
|
797
|
+
function resolveNormalizedMembers(members) {
|
|
798
|
+
let normalized = members.map((member) => normalizeField(member)).filter((member) => !opaqueTypes.has(member.type));
|
|
799
|
+
return isDefined(normalized) ? normalized : void 0;
|
|
1501
800
|
}
|
|
1502
801
|
/**
|
|
1503
|
-
*
|
|
1504
|
-
* title and falling back to a title-cased name.
|
|
802
|
+
* Works out a value's parent type name, looking it up in the schema when the value only names its type.
|
|
1505
803
|
*
|
|
1506
|
-
* @param
|
|
1507
|
-
* @
|
|
804
|
+
* @param value - The value.
|
|
805
|
+
* @param schema - The Sanity schema.
|
|
806
|
+
* @returns The parent type name, or undefined when there isn't one.
|
|
1508
807
|
*/
|
|
1509
|
-
function
|
|
1510
|
-
let
|
|
1511
|
-
|
|
808
|
+
function resolveParentName(value, schema) {
|
|
809
|
+
let direct = getParentTypeName(value);
|
|
810
|
+
if (isDefined(direct)) return direct;
|
|
811
|
+
let typeName = getTypeName(value);
|
|
812
|
+
if (!isDefined(typeName)) return;
|
|
813
|
+
let resolvedType = schema.get(typeName);
|
|
814
|
+
return isDefined(resolvedType) ? getParentTypeName(resolvedType) : void 0;
|
|
1512
815
|
}
|
|
1513
816
|
/**
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
817
|
+
* Works out the fields a value shows, whether it holds them directly, has array members that do, or
|
|
818
|
+
* names a type that does.
|
|
1516
819
|
*
|
|
1517
|
-
* @param
|
|
1518
|
-
* @
|
|
820
|
+
* @param value - The value.
|
|
821
|
+
* @param schema - The Sanity schema.
|
|
822
|
+
* @returns The fields, or undefined when there are none.
|
|
1519
823
|
*/
|
|
1520
|
-
function
|
|
1521
|
-
|
|
1522
|
-
|
|
824
|
+
function resolveFields(value, schema) {
|
|
825
|
+
if (hasFieldsArray(value)) {
|
|
826
|
+
let parentName = resolveParentName(value, schema);
|
|
827
|
+
return isDefined(parentName) && opaqueTypes.has(parentName) ? resolveCustomFields(value, parentName) : resolveNormalizedFields(value.fields);
|
|
828
|
+
}
|
|
829
|
+
if (hasOfArray(value)) {
|
|
830
|
+
let members = value.of;
|
|
831
|
+
if (members.length === 1) {
|
|
832
|
+
let [member] = members, normalized = normalizeField(member);
|
|
833
|
+
if (opaqueTypes.has(normalized.type)) return;
|
|
834
|
+
if (hasFieldsArray(normalized)) {
|
|
835
|
+
let parentName = resolveParentName(normalized, schema);
|
|
836
|
+
return isDefined(parentName) && opaqueTypes.has(parentName) ? resolveCustomFields(normalized, parentName) : resolveNormalizedFields(normalized.fields);
|
|
837
|
+
}
|
|
838
|
+
let memberType = schema.get(normalized.type);
|
|
839
|
+
if (isDefined(memberType)) return resolveFields(memberType, schema);
|
|
840
|
+
}
|
|
841
|
+
return resolveNormalizedMembers(members);
|
|
842
|
+
}
|
|
1523
843
|
}
|
|
1524
844
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
* carry instead. A consumer's icon is redrawn at the plugin's own weight, so it sits beside the
|
|
1527
|
-
* built-in ones rather than at its own library's default size.
|
|
845
|
+
* Works out a field's visible subfields by looking through the schema.
|
|
1528
846
|
*
|
|
1529
|
-
* @param
|
|
1530
|
-
* @
|
|
847
|
+
* @param field - The field.
|
|
848
|
+
* @param schema - The Sanity schema.
|
|
849
|
+
* @returns The subfields, or undefined when there are none.
|
|
1531
850
|
*/
|
|
1532
|
-
function
|
|
1533
|
-
|
|
851
|
+
function getSubfields(field, schema) {
|
|
852
|
+
if (opaqueTypes.has(field.type)) return;
|
|
853
|
+
let directFields = resolveFields(field, schema);
|
|
854
|
+
if (isDefined(directFields)) return directFields;
|
|
855
|
+
let resolvedType = schema.get(field.type);
|
|
856
|
+
if (!isDefined(resolvedType)) return;
|
|
857
|
+
let parentName = getParentTypeName(resolvedType);
|
|
858
|
+
return isDefined(parentName) && opaqueTypes.has(parentName) ? resolveCustomFields(resolvedType, parentName) : resolveFields(resolvedType, schema);
|
|
1534
859
|
}
|
|
1535
|
-
/**
|
|
1536
|
-
const opaqueTypes = /* @__PURE__ */ new Set([
|
|
1537
|
-
"block",
|
|
1538
|
-
"boolean",
|
|
1539
|
-
"crossDatasetReference",
|
|
1540
|
-
"date",
|
|
1541
|
-
"datetime",
|
|
1542
|
-
"file",
|
|
1543
|
-
"geopoint",
|
|
1544
|
-
"image",
|
|
1545
|
-
"number",
|
|
1546
|
-
"reference",
|
|
1547
|
-
"slug",
|
|
1548
|
-
"string",
|
|
1549
|
-
"text",
|
|
1550
|
-
"url"
|
|
1551
|
-
]), inheritedFieldNames = {
|
|
1552
|
-
block: /* @__PURE__ */ new Set([
|
|
1553
|
-
"children",
|
|
1554
|
-
"level",
|
|
1555
|
-
"listItem",
|
|
1556
|
-
"markDefs",
|
|
1557
|
-
"style"
|
|
1558
|
-
]),
|
|
1559
|
-
file: /* @__PURE__ */ new Set(["asset", "media"]),
|
|
1560
|
-
geopoint: /* @__PURE__ */ new Set([
|
|
1561
|
-
"alt",
|
|
1562
|
-
"lat",
|
|
1563
|
-
"lng"
|
|
1564
|
-
]),
|
|
1565
|
-
image: /* @__PURE__ */ new Set([
|
|
1566
|
-
"asset",
|
|
1567
|
-
"crop",
|
|
1568
|
-
"hotspot",
|
|
1569
|
-
"media"
|
|
1570
|
-
]),
|
|
1571
|
-
slug: /* @__PURE__ */ new Set(["current", "source"])
|
|
1572
|
-
};
|
|
1573
|
-
/**
|
|
1574
|
-
* Checks whether a value is a compiled schema field with a nested type object.
|
|
1575
|
-
*
|
|
1576
|
-
* @param value - The value to check.
|
|
1577
|
-
* @returns True if the value is a compiled field.
|
|
1578
|
-
*/
|
|
1579
|
-
function isCompiledField(value) {
|
|
1580
|
-
return typeof value != "object" || !value || !("name" in value) || !("type" in value) ? !1 : typeof value.type == "object" && value.type !== null;
|
|
1581
|
-
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Checks whether a value has a `fields` array property.
|
|
1584
|
-
*
|
|
1585
|
-
* @param value - The value to check.
|
|
1586
|
-
* @returns True if the value contains a `fields` array.
|
|
1587
|
-
*/
|
|
1588
|
-
function hasFieldsArray(value) {
|
|
1589
|
-
return typeof value != "object" || !value || !("fields" in value) ? !1 : Array.isArray(value.fields);
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Checks whether a value has an `of` array property.
|
|
1593
|
-
*
|
|
1594
|
-
* @param value - The value to check.
|
|
1595
|
-
* @returns True if the value contains an `of` array.
|
|
1596
|
-
*/
|
|
1597
|
-
function hasOfArray(value) {
|
|
1598
|
-
return typeof value != "object" || !value || !("of" in value) ? !1 : Array.isArray(value.of);
|
|
1599
|
-
}
|
|
1600
|
-
/**
|
|
1601
|
-
* Extracts the type name a value declares, where it names one at all.
|
|
1602
|
-
*
|
|
1603
|
-
* @param value - The value to inspect.
|
|
1604
|
-
* @returns The type name, or undefined when the value declares none.
|
|
1605
|
-
*/
|
|
1606
|
-
function getTypeName(value) {
|
|
1607
|
-
if (typeof value == "object" && value && "type" in value) return typeof value.type == "string" ? value.type : void 0;
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
|
-
* Extracts the parent type name from a compiled schema type, if present.
|
|
1611
|
-
*
|
|
1612
|
-
* @param resolvedType - The compiled schema type to inspect.
|
|
1613
|
-
* @returns The parent type name, or undefined when the type extends none.
|
|
1614
|
-
*/
|
|
1615
|
-
function getParentTypeName(resolvedType) {
|
|
1616
|
-
if (typeof resolvedType == "object" && resolvedType && "type" in resolvedType && typeof resolvedType.type == "object" && resolvedType.type !== null && "name" in resolvedType.type) return String(resolvedType.type.name);
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Normalises a compiled schema field into the shape the Handbook renders. Type names already seen are
|
|
1620
|
-
* tracked so a type that refers back to itself does not recurse forever.
|
|
1621
|
-
*
|
|
1622
|
-
* @param field - A compiled schema field or plain field definition.
|
|
1623
|
-
* @param visited - Type names already seen in this normalisation chain.
|
|
1624
|
-
* @returns The normalised field.
|
|
1625
|
-
*/
|
|
1626
|
-
function normaliseField(field, visited = /* @__PURE__ */ new Set()) {
|
|
1627
|
-
if (isCompiledField(field)) {
|
|
1628
|
-
let typeName = field.type.name, result = {
|
|
1629
|
-
name: field.name,
|
|
1630
|
-
type: typeName,
|
|
1631
|
-
title: field.title ?? field.type.title,
|
|
1632
|
-
description: field.description ?? field.type.description,
|
|
1633
|
-
handbook: field.handbook
|
|
1634
|
-
};
|
|
1635
|
-
if (!visited.has(typeName)) {
|
|
1636
|
-
let next = !opaqueTypes.has(typeName) && typeName !== "object" && typeName !== "array" ? /* @__PURE__ */ new Set([...visited, typeName]) : visited, fieldSource = hasFieldsArray(field) ? field : field.type, ofSource = hasOfArray(field) ? field : field.type;
|
|
1637
|
-
hasFieldsArray(fieldSource) && (result.fields = fieldSource.fields.map((subfield) => normaliseField(subfield, next))), hasOfArray(ofSource) && (result.of = ofSource.of.map((member) => normaliseField(member, next)));
|
|
1638
|
-
}
|
|
1639
|
-
return result;
|
|
1640
|
-
}
|
|
1641
|
-
return field;
|
|
1642
|
-
}
|
|
1643
|
-
/**
|
|
1644
|
-
* Resolves only the fields a custom type adds on top of an opaque base type, leaving out the ones the
|
|
1645
|
-
* base type contributes of its own accord.
|
|
1646
|
-
*
|
|
1647
|
-
* @param resolvedType - The compiled or normalised schema type.
|
|
1648
|
-
* @param parentName - The opaque base type name.
|
|
1649
|
-
* @returns The custom fields, or undefined when the type adds none.
|
|
1650
|
-
*/
|
|
1651
|
-
function resolveCustomFields(resolvedType, parentName) {
|
|
1652
|
-
if (!hasFieldsArray(resolvedType)) return;
|
|
1653
|
-
let inherited = inheritedFieldNames[parentName], customFields = resolvedType.fields.map((field) => normaliseField(field)).filter((field) => !isDefined(inherited) || !inherited.has(field.name));
|
|
1654
|
-
return isDefined(customFields) ? customFields : void 0;
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Normalises a list of raw field values into the shape the Handbook renders.
|
|
1658
|
-
*
|
|
1659
|
-
* @param items - Raw field values to normalise.
|
|
1660
|
-
* @returns The normalised fields, or undefined when the list holds none.
|
|
1661
|
-
*/
|
|
1662
|
-
function resolveNormalisedFields(items) {
|
|
1663
|
-
let normalised = items.map((item) => normaliseField(item));
|
|
1664
|
-
return isDefined(normalised) ? normalised : void 0;
|
|
1665
|
-
}
|
|
1666
|
-
/**
|
|
1667
|
-
* Normalises array members and filters out opaque types that have no meaningful subfields.
|
|
1668
|
-
*
|
|
1669
|
-
* @param members - Raw array member values to normalise.
|
|
1670
|
-
* @returns The normalised non-opaque members, or undefined when none remain.
|
|
1671
|
-
*/
|
|
1672
|
-
function resolveNormalisedMembers(members) {
|
|
1673
|
-
let normalised = members.map((member) => normaliseField(member)).filter((member) => !opaqueTypes.has(member.type));
|
|
1674
|
-
return isDefined(normalised) ? normalised : void 0;
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
* Resolves the name of the type a value extends, reaching into the schema registry when the value
|
|
1678
|
-
* carries nothing but a type name of its own.
|
|
1679
|
-
*
|
|
1680
|
-
* @param value - The value to inspect.
|
|
1681
|
-
* @param schema - The Sanity schema registry.
|
|
1682
|
-
* @returns The parent type name, or undefined when the value extends none.
|
|
1683
|
-
*/
|
|
1684
|
-
function resolveParentName(value, schema) {
|
|
1685
|
-
let direct = getParentTypeName(value);
|
|
1686
|
-
if (isDefined(direct)) return direct;
|
|
1687
|
-
let typeName = getTypeName(value);
|
|
1688
|
-
if (!isDefined(typeName)) return;
|
|
1689
|
-
let resolvedType = schema.get(typeName);
|
|
1690
|
-
return isDefined(resolvedType) ? getParentTypeName(resolvedType) : void 0;
|
|
1691
|
-
}
|
|
1692
|
-
/**
|
|
1693
|
-
* Extracts the fields a value displays, whether it carries them directly, carries array members that
|
|
1694
|
-
* do, or names a type that does.
|
|
1695
|
-
*
|
|
1696
|
-
* @param value - The value to extract fields from.
|
|
1697
|
-
* @param schema - The Sanity schema registry.
|
|
1698
|
-
* @returns The resolved fields, or undefined when the value has none.
|
|
1699
|
-
*/
|
|
1700
|
-
function resolveFields(value, schema) {
|
|
1701
|
-
if (hasFieldsArray(value)) {
|
|
1702
|
-
let parentName = resolveParentName(value, schema);
|
|
1703
|
-
return isDefined(parentName) && opaqueTypes.has(parentName) ? resolveCustomFields(value, parentName) : resolveNormalisedFields(value.fields);
|
|
1704
|
-
}
|
|
1705
|
-
if (hasOfArray(value)) {
|
|
1706
|
-
let members = value.of;
|
|
1707
|
-
if (members.length === 1) {
|
|
1708
|
-
let [member] = members, normalised = normaliseField(member);
|
|
1709
|
-
if (opaqueTypes.has(normalised.type)) return;
|
|
1710
|
-
if (hasFieldsArray(normalised)) {
|
|
1711
|
-
let parentName = resolveParentName(normalised, schema);
|
|
1712
|
-
return isDefined(parentName) && opaqueTypes.has(parentName) ? resolveCustomFields(normalised, parentName) : resolveNormalisedFields(normalised.fields);
|
|
1713
|
-
}
|
|
1714
|
-
let memberType = schema.get(normalised.type);
|
|
1715
|
-
if (isDefined(memberType)) return resolveFields(memberType, schema);
|
|
1716
|
-
}
|
|
1717
|
-
return resolveNormalisedMembers(members);
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
* Resolves the displayable subfields of a field definition by traversing the schema.
|
|
1722
|
-
*
|
|
1723
|
-
* @param field - The parent field definition.
|
|
1724
|
-
* @param schema - The Sanity schema registry.
|
|
1725
|
-
* @returns The non-opaque subfields, or undefined when the field has none.
|
|
1726
|
-
*/
|
|
1727
|
-
function getSubfields(field, schema) {
|
|
1728
|
-
if (opaqueTypes.has(field.type)) return;
|
|
1729
|
-
let directFields = resolveFields(field, schema);
|
|
1730
|
-
if (isDefined(directFields)) return directFields;
|
|
1731
|
-
let resolvedType = schema.get(field.type);
|
|
1732
|
-
if (!isDefined(resolvedType)) return;
|
|
1733
|
-
let parentName = getParentTypeName(resolvedType);
|
|
1734
|
-
return isDefined(parentName) && opaqueTypes.has(parentName) ? resolveCustomFields(resolvedType, parentName) : resolveFields(resolvedType, schema);
|
|
1735
|
-
}
|
|
1736
|
-
/** Shared empty ancestor set, so the default prop keeps a stable reference across renders. */
|
|
860
|
+
/** Shared empty set, so the default prop keeps the same reference between renders. */
|
|
1737
861
|
const noAncestors = /* @__PURE__ */ new Set();
|
|
1738
|
-
function
|
|
862
|
+
function DocumentedField(t0) {
|
|
1739
863
|
let $ = c(59), field, props, t1;
|
|
1740
864
|
$[0] === t0 ? (field = $[1], props = $[2], t1 = $[3]) : ({field, ancestors: t1, ...props} = t0, $[0] = t0, $[1] = field, $[2] = props, $[3] = t1);
|
|
1741
865
|
let ancestors = t1 === void 0 ? noAncestors : t1, schema = useSchema(), { undocumentedFieldMessage } = useHandbookContext(), [expanded, setExpanded] = useState(!1), t2;
|
|
@@ -1865,7 +989,7 @@ function Field(t0) {
|
|
|
1865
989
|
]
|
|
1866
990
|
})]
|
|
1867
991
|
})
|
|
1868
|
-
}), expanded && /* @__PURE__ */ jsx(
|
|
992
|
+
}), expanded && /* @__PURE__ */ jsx(Box, {
|
|
1869
993
|
style: {
|
|
1870
994
|
marginTop: 16,
|
|
1871
995
|
marginBottom: 8,
|
|
@@ -1874,7 +998,7 @@ function Field(t0) {
|
|
|
1874
998
|
},
|
|
1875
999
|
children: /* @__PURE__ */ jsx(Stack, {
|
|
1876
1000
|
gap: 5,
|
|
1877
|
-
children: subfields.map((subfield) => /* @__PURE__ */ jsx(
|
|
1001
|
+
children: subfields.map((subfield) => /* @__PURE__ */ jsx(DocumentedField, {
|
|
1878
1002
|
field: subfield,
|
|
1879
1003
|
ancestors: /* @__PURE__ */ new Set([...ancestors, field.type])
|
|
1880
1004
|
}, subfield.name))
|
|
@@ -1886,10 +1010,10 @@ function Field(t0) {
|
|
|
1886
1010
|
return t6;
|
|
1887
1011
|
}
|
|
1888
1012
|
/**
|
|
1889
|
-
* Builds a section for each
|
|
1013
|
+
* Builds a sidebar section for each document role.
|
|
1890
1014
|
*
|
|
1891
|
-
* @param roles -
|
|
1892
|
-
* @returns One section per role,
|
|
1015
|
+
* @param roles - The configured document roles.
|
|
1016
|
+
* @returns One section per role, with an entry per document type.
|
|
1893
1017
|
*/
|
|
1894
1018
|
function documentTypesSections(roles) {
|
|
1895
1019
|
return roles.map(({ title, documents }) => ({
|
|
@@ -1905,7 +1029,7 @@ function documentTypesSections(roles) {
|
|
|
1905
1029
|
flexDirection: "column",
|
|
1906
1030
|
gap: contentSpacing.section
|
|
1907
1031
|
},
|
|
1908
|
-
children: document.fields.map((field) => /* @__PURE__ */ jsx(
|
|
1032
|
+
children: document.fields.map((field) => /* @__PURE__ */ jsx(DocumentedField, { field }, field.name))
|
|
1909
1033
|
})
|
|
1910
1034
|
}))
|
|
1911
1035
|
}));
|
|
@@ -2019,11 +1143,10 @@ function DocumentTypesOverview() {
|
|
|
2019
1143
|
align: "center",
|
|
2020
1144
|
gap: 2,
|
|
2021
1145
|
style: { marginLeft: "-4px" },
|
|
2022
|
-
children: [isDefined(Icon) && /* @__PURE__ */ jsx(
|
|
1146
|
+
children: [isDefined(Icon) && /* @__PURE__ */ jsx(Flex, {
|
|
1147
|
+
align: "center",
|
|
1148
|
+
justify: "center",
|
|
2023
1149
|
style: {
|
|
2024
|
-
display: "flex",
|
|
2025
|
-
alignItems: "center",
|
|
2026
|
-
justifyContent: "center",
|
|
2027
1150
|
width: 25,
|
|
2028
1151
|
height: 25,
|
|
2029
1152
|
color: "var(--card-icon-color)"
|
|
@@ -2066,11 +1189,11 @@ function DocumentTypesOverview() {
|
|
|
2066
1189
|
children: t1
|
|
2067
1190
|
}), $[8] = t1, $[9] = t2), t2;
|
|
2068
1191
|
}
|
|
2069
|
-
/** What each hint kind
|
|
1192
|
+
/** What each hint kind means, shown next to its icon as a key. */
|
|
2070
1193
|
const hintDescriptions = {
|
|
2071
|
-
tip: "
|
|
2072
|
-
info: "
|
|
2073
|
-
caution: "
|
|
1194
|
+
tip: "Tips and suggested practices for people editing content.",
|
|
1195
|
+
info: "More detail about how and where the field is used.",
|
|
1196
|
+
caution: "Warnings about restrictions or problems the field can cause."
|
|
2074
1197
|
};
|
|
2075
1198
|
function HowToUse() {
|
|
2076
1199
|
let $ = c(8), t0;
|
|
@@ -2093,7 +1216,7 @@ function HowToUse() {
|
|
|
2093
1216
|
}), /* @__PURE__ */ jsx(Text, {
|
|
2094
1217
|
size: 1,
|
|
2095
1218
|
muted: !0,
|
|
2096
|
-
children: "The sidebar lists everything the Handbook
|
|
1219
|
+
children: "The sidebar lists everything in the Handbook: these introductory pages first, then the document types you can create, grouped by their role on the site, and then any guides your team has written. Select an entry to open it here."
|
|
2097
1220
|
})]
|
|
2098
1221
|
}), $[1] = t1) : t1 = $[1];
|
|
2099
1222
|
let t2;
|
|
@@ -2110,7 +1233,7 @@ function HowToUse() {
|
|
|
2110
1233
|
}), /* @__PURE__ */ jsx(Text, {
|
|
2111
1234
|
size: 1,
|
|
2112
1235
|
muted: !0,
|
|
2113
|
-
children: "Selecting a document type lists its fields, each
|
|
1236
|
+
children: "Selecting a document type lists its fields, with each field’s name, the kind of value it holds, and what it’s for. This documentation is generated from the content model, so it always matches what you see in the editor."
|
|
2114
1237
|
})]
|
|
2115
1238
|
}), $[2] = t2) : t2 = $[2];
|
|
2116
1239
|
let t3, t4;
|
|
@@ -2125,7 +1248,7 @@ function HowToUse() {
|
|
|
2125
1248
|
}), t4 = /* @__PURE__ */ jsx(Text, {
|
|
2126
1249
|
size: 1,
|
|
2127
1250
|
muted: !0,
|
|
2128
|
-
children: "Icons
|
|
1251
|
+
children: "Icons next to a field’s name hold extra guidance that would make its description too long. Hover over or click an icon to read it, and use the key below to see what each icon means."
|
|
2129
1252
|
}), $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]);
|
|
2130
1253
|
let t5;
|
|
2131
1254
|
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsxs(Stack, {
|
|
@@ -2136,7 +1259,7 @@ function HowToUse() {
|
|
|
2136
1259
|
/* @__PURE__ */ jsx(Stack, {
|
|
2137
1260
|
gap: 3,
|
|
2138
1261
|
marginTop: 2,
|
|
2139
|
-
children: hintKinds.map(_temp$
|
|
1262
|
+
children: hintKinds.map(_temp$3)
|
|
2140
1263
|
})
|
|
2141
1264
|
]
|
|
2142
1265
|
}), $[5] = t5) : t5 = $[5];
|
|
@@ -2154,7 +1277,7 @@ function HowToUse() {
|
|
|
2154
1277
|
}), /* @__PURE__ */ jsx(Text, {
|
|
2155
1278
|
size: 1,
|
|
2156
1279
|
muted: !0,
|
|
2157
|
-
children: "Some fields
|
|
1280
|
+
children: "Some fields contain subfields, such as a content block with a heading and body text. A button below the description shows how many there are and expands to list them, each documented like any other field."
|
|
2158
1281
|
})]
|
|
2159
1282
|
}), $[6] = t6) : t6 = $[6];
|
|
2160
1283
|
let t7;
|
|
@@ -2178,22 +1301,21 @@ function HowToUse() {
|
|
|
2178
1301
|
}), /* @__PURE__ */ jsx(Text, {
|
|
2179
1302
|
size: 1,
|
|
2180
1303
|
muted: !0,
|
|
2181
|
-
children: "
|
|
1304
|
+
children: "Below the document types, you may find guides written by your team rather than generated from the content model. They cover things a field description can’t, such as house style, editorial process, and how everything fits together."
|
|
2182
1305
|
})]
|
|
2183
1306
|
})
|
|
2184
1307
|
]
|
|
2185
1308
|
}), $[7] = t7) : t7 = $[7], t7;
|
|
2186
1309
|
}
|
|
2187
|
-
function _temp$
|
|
1310
|
+
function _temp$3(t0) {
|
|
2188
1311
|
let { name, icon: Icon } = t0;
|
|
2189
1312
|
return /* @__PURE__ */ jsxs(Flex, {
|
|
2190
1313
|
align: "center",
|
|
2191
1314
|
gap: 3,
|
|
2192
|
-
children: [/* @__PURE__ */ jsx(
|
|
1315
|
+
children: [/* @__PURE__ */ jsx(Flex, {
|
|
1316
|
+
align: "center",
|
|
1317
|
+
flex: "none",
|
|
2193
1318
|
style: {
|
|
2194
|
-
display: "flex",
|
|
2195
|
-
alignItems: "center",
|
|
2196
|
-
flexShrink: 0,
|
|
2197
1319
|
fontSize: "16px",
|
|
2198
1320
|
color: "var(--card-icon-color)"
|
|
2199
1321
|
},
|
|
@@ -2206,9 +1328,9 @@ function _temp$2(t0) {
|
|
|
2206
1328
|
}, name);
|
|
2207
1329
|
}
|
|
2208
1330
|
/**
|
|
2209
|
-
* Builds the section
|
|
1331
|
+
* Builds the section for the plugin's introductory pages.
|
|
2210
1332
|
*
|
|
2211
|
-
* @returns
|
|
1333
|
+
* @returns One section listing the built-in pages.
|
|
2212
1334
|
*/
|
|
2213
1335
|
function gettingStartedSections() {
|
|
2214
1336
|
return [{
|
|
@@ -2216,18 +1338,89 @@ function gettingStartedSections() {
|
|
|
2216
1338
|
entries: [{
|
|
2217
1339
|
id: "how-to-use-this-handbook",
|
|
2218
1340
|
title: "How to use the Handbook",
|
|
2219
|
-
description: "
|
|
1341
|
+
description: "How to find your way around the Handbook, read the documentation for each field, and understand its examples, hints, and subfields.",
|
|
2220
1342
|
icon: createSanityIcon(BookTextIcon),
|
|
2221
1343
|
render: () => /* @__PURE__ */ jsx(HowToUse, {})
|
|
2222
1344
|
}, {
|
|
2223
1345
|
id: "document-types",
|
|
2224
1346
|
title: "Document Types",
|
|
2225
|
-
description: "
|
|
1347
|
+
description: "A list of every document type, grouped by role. Select a document type to see its fields, descriptions, and examples.",
|
|
2226
1348
|
icon: createSanityIcon(LayoutGridIcon),
|
|
2227
1349
|
render: () => /* @__PURE__ */ jsx(DocumentTypesOverview, {})
|
|
2228
1350
|
}]
|
|
2229
1351
|
}];
|
|
2230
1352
|
}
|
|
1353
|
+
/** Icon and tone for each callout variant. */
|
|
1354
|
+
const presentation = {
|
|
1355
|
+
tip: {
|
|
1356
|
+
icon: LightbulbIcon,
|
|
1357
|
+
tone: "positive"
|
|
1358
|
+
},
|
|
1359
|
+
info: {
|
|
1360
|
+
icon: InfoIcon,
|
|
1361
|
+
tone: "primary"
|
|
1362
|
+
},
|
|
1363
|
+
warning: {
|
|
1364
|
+
icon: TriangleAlertIcon,
|
|
1365
|
+
tone: "caution"
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
function CalloutContent(t0) {
|
|
1369
|
+
let $ = c(17), children, props, variant;
|
|
1370
|
+
$[0] === t0 ? (children = $[1], props = $[2], variant = $[3]) : ({variant, children, ...props} = t0, $[0] = t0, $[1] = children, $[2] = props, $[3] = variant);
|
|
1371
|
+
let { icon: Icon, tone } = presentation[variant], t1;
|
|
1372
|
+
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
1373
|
+
marginTop: "-2px",
|
|
1374
|
+
fontSize: "16px",
|
|
1375
|
+
color: "var(--card-icon-color)"
|
|
1376
|
+
}, $[4] = t1) : t1 = $[4];
|
|
1377
|
+
let t2;
|
|
1378
|
+
$[5] === Icon ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx(Box, {
|
|
1379
|
+
flex: "none",
|
|
1380
|
+
style: t1,
|
|
1381
|
+
children: /* @__PURE__ */ jsx(Icon, { ...defaultIconProps })
|
|
1382
|
+
}), $[5] = Icon, $[6] = t2);
|
|
1383
|
+
let t3;
|
|
1384
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = { color: "var(--card-icon-color)" }, $[7] = t3) : t3 = $[7];
|
|
1385
|
+
let t4;
|
|
1386
|
+
$[8] === children ? t4 = $[9] : (t4 = /* @__PURE__ */ jsx(Text, {
|
|
1387
|
+
size: 1,
|
|
1388
|
+
style: t3,
|
|
1389
|
+
children
|
|
1390
|
+
}), $[8] = children, $[9] = t4);
|
|
1391
|
+
let t5;
|
|
1392
|
+
$[10] !== t2 || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, {
|
|
1393
|
+
align: "flex-start",
|
|
1394
|
+
gap: 3,
|
|
1395
|
+
children: [t2, t4]
|
|
1396
|
+
}), $[10] = t2, $[11] = t4, $[12] = t5) : t5 = $[12];
|
|
1397
|
+
let t6;
|
|
1398
|
+
return $[13] !== props || $[14] !== t5 || $[15] !== tone ? (t6 = /* @__PURE__ */ jsx(Card, {
|
|
1399
|
+
padding: 4,
|
|
1400
|
+
radius: 2,
|
|
1401
|
+
tone,
|
|
1402
|
+
...props,
|
|
1403
|
+
children: t5
|
|
1404
|
+
}), $[13] = props, $[14] = t5, $[15] = tone, $[16] = t6) : t6 = $[16], t6;
|
|
1405
|
+
}
|
|
1406
|
+
function PortableCode(t0) {
|
|
1407
|
+
let $ = c(8), props, style;
|
|
1408
|
+
$[0] === t0 ? (props = $[1], style = $[2]) : ({style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style);
|
|
1409
|
+
let t1;
|
|
1410
|
+
$[3] === style ? t1 = $[4] : (t1 = {
|
|
1411
|
+
paddingBlock: 2,
|
|
1412
|
+
paddingInline: 4,
|
|
1413
|
+
fontSize: "0.875em",
|
|
1414
|
+
backgroundColor: "var(--card-code-bg-color)",
|
|
1415
|
+
borderRadius: 2,
|
|
1416
|
+
...style
|
|
1417
|
+
}, $[3] = style, $[4] = t1);
|
|
1418
|
+
let t2;
|
|
1419
|
+
return $[5] !== props || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsx("code", {
|
|
1420
|
+
style: t1,
|
|
1421
|
+
...props
|
|
1422
|
+
}), $[5] = props, $[6] = t1, $[7] = t2) : t2 = $[7], t2;
|
|
1423
|
+
}
|
|
2231
1424
|
function PortableLink(t0) {
|
|
2232
1425
|
let $ = c(10), children, props, style;
|
|
2233
1426
|
$[0] === t0 ? (children = $[1], props = $[2], style = $[3]) : ({children, style, ...props} = t0, $[0] = t0, $[1] = children, $[2] = props, $[3] = style);
|
|
@@ -2245,7 +1438,7 @@ function PortableLink(t0) {
|
|
|
2245
1438
|
children
|
|
2246
1439
|
}), $[6] = children, $[7] = props, $[8] = t1, $[9] = t2) : t2 = $[9], t2;
|
|
2247
1440
|
}
|
|
2248
|
-
/** Overrides for
|
|
1441
|
+
/** Overrides for callout text, which uses the card's own text style and doesn't wrap paragraphs. */
|
|
2249
1442
|
const components$1 = {
|
|
2250
1443
|
block: { normal: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children }) },
|
|
2251
1444
|
marks: {
|
|
@@ -2277,6 +1470,30 @@ function CalloutBlock(t0) {
|
|
|
2277
1470
|
children: t2
|
|
2278
1471
|
}), $[8] = props, $[9] = t1, $[10] = t2, $[11] = value.variant, $[12] = t3) : t3 = $[12], t3;
|
|
2279
1472
|
}
|
|
1473
|
+
function CodeContent(t0) {
|
|
1474
|
+
let $ = c(14), code, language, props, style;
|
|
1475
|
+
$[0] === t0 ? (code = $[1], language = $[2], props = $[3], style = $[4]) : ({code, language, style, ...props} = t0, $[0] = t0, $[1] = code, $[2] = language, $[3] = props, $[4] = style);
|
|
1476
|
+
let t1;
|
|
1477
|
+
$[5] === style ? t1 = $[6] : (t1 = {
|
|
1478
|
+
overflowX: "auto",
|
|
1479
|
+
...style
|
|
1480
|
+
}, $[5] = style, $[6] = t1);
|
|
1481
|
+
let t2;
|
|
1482
|
+
$[7] !== code || $[8] !== language ? (t2 = /* @__PURE__ */ jsx(Code, {
|
|
1483
|
+
size: 1,
|
|
1484
|
+
language,
|
|
1485
|
+
children: code
|
|
1486
|
+
}), $[7] = code, $[8] = language, $[9] = t2) : t2 = $[9];
|
|
1487
|
+
let t3;
|
|
1488
|
+
return $[10] !== props || $[11] !== t1 || $[12] !== t2 ? (t3 = /* @__PURE__ */ jsx(Card, {
|
|
1489
|
+
padding: 4,
|
|
1490
|
+
radius: 2,
|
|
1491
|
+
tone: "transparent",
|
|
1492
|
+
style: t1,
|
|
1493
|
+
...props,
|
|
1494
|
+
children: t2
|
|
1495
|
+
}), $[10] = props, $[11] = t1, $[12] = t2, $[13] = t3) : t3 = $[13], t3;
|
|
1496
|
+
}
|
|
2280
1497
|
function CodeBlock(t0) {
|
|
2281
1498
|
let $ = c(11), props, style, value;
|
|
2282
1499
|
if ($[0] === t0 ? (props = $[1], style = $[2], value = $[3]) : ({value, style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style, $[3] = value), !isDefined(value.code)) return null;
|
|
@@ -2293,6 +1510,21 @@ function CodeBlock(t0) {
|
|
|
2293
1510
|
...props
|
|
2294
1511
|
}), $[6] = props, $[7] = t1, $[8] = value.code, $[9] = value.language, $[10] = t2) : t2 = $[10], t2;
|
|
2295
1512
|
}
|
|
1513
|
+
function HorizontalRuleContent(t0) {
|
|
1514
|
+
let $ = c(8), props, style;
|
|
1515
|
+
$[0] === t0 ? (props = $[1], style = $[2]) : ({style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style);
|
|
1516
|
+
let t1;
|
|
1517
|
+
$[3] === style ? t1 = $[4] : (t1 = {
|
|
1518
|
+
border: "none",
|
|
1519
|
+
borderTop: "1px solid var(--card-border-color)",
|
|
1520
|
+
...style
|
|
1521
|
+
}, $[3] = style, $[4] = t1);
|
|
1522
|
+
let t2;
|
|
1523
|
+
return $[5] !== props || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsx("hr", {
|
|
1524
|
+
style: t1,
|
|
1525
|
+
...props
|
|
1526
|
+
}), $[5] = props, $[6] = t1, $[7] = t2) : t2 = $[7], t2;
|
|
1527
|
+
}
|
|
2296
1528
|
function HorizontalRuleBlock(t0) {
|
|
2297
1529
|
let $ = c(8), props, style;
|
|
2298
1530
|
if ($[0] !== t0) {
|
|
@@ -2310,32 +1542,104 @@ function HorizontalRuleBlock(t0) {
|
|
|
2310
1542
|
...props
|
|
2311
1543
|
}), $[5] = props, $[6] = t1, $[7] = t2) : t2 = $[7], t2;
|
|
2312
1544
|
}
|
|
2313
|
-
function
|
|
2314
|
-
let $ = c(
|
|
2315
|
-
|
|
1545
|
+
function Caption(t0) {
|
|
1546
|
+
let $ = c(9), children, props;
|
|
1547
|
+
$[0] === t0 ? (children = $[1], props = $[2]) : ({children, ...props} = t0, $[0] = t0, $[1] = children, $[2] = props);
|
|
2316
1548
|
let t1;
|
|
2317
|
-
$[
|
|
2318
|
-
marginBlock: contentSpacing.media,
|
|
2319
|
-
...style
|
|
2320
|
-
}, $[4] = style, $[5] = t1);
|
|
1549
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t1 = { fontStyle: "italic" }, $[3] = t1) : t1 = $[3];
|
|
2321
1550
|
let t2;
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
caption: value.caption,
|
|
1551
|
+
$[4] === children ? t2 = $[5] : (t2 = /* @__PURE__ */ jsx(Text, {
|
|
1552
|
+
size: 1,
|
|
1553
|
+
muted: !0,
|
|
2326
1554
|
style: t1,
|
|
2327
|
-
|
|
2328
|
-
}), $[
|
|
1555
|
+
children
|
|
1556
|
+
}), $[4] = children, $[5] = t2);
|
|
1557
|
+
let t3;
|
|
1558
|
+
return $[6] !== props || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, {
|
|
1559
|
+
marginTop: 3,
|
|
1560
|
+
...props,
|
|
1561
|
+
children: t2
|
|
1562
|
+
}), $[6] = props, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
|
|
2329
1563
|
}
|
|
2330
|
-
function
|
|
2331
|
-
let $ = c(
|
|
2332
|
-
|
|
2333
|
-
let t1;
|
|
2334
|
-
$[
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
1564
|
+
function ImageContent(t0) {
|
|
1565
|
+
let $ = c(15), alt, caption, props, url;
|
|
1566
|
+
$[0] === t0 ? (alt = $[1], caption = $[2], props = $[3], url = $[4]) : ({url, alt, caption, ...props} = t0, $[0] = t0, $[1] = alt, $[2] = caption, $[3] = props, $[4] = url);
|
|
1567
|
+
let t1 = alt ?? "", t2;
|
|
1568
|
+
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
1569
|
+
display: "block",
|
|
1570
|
+
maxWidth: "100%",
|
|
1571
|
+
borderRadius: 4
|
|
1572
|
+
}, $[5] = t2) : t2 = $[5];
|
|
1573
|
+
let t3;
|
|
1574
|
+
$[6] !== t1 || $[7] !== url ? (t3 = /* @__PURE__ */ jsx("img", {
|
|
1575
|
+
src: url,
|
|
1576
|
+
alt: t1,
|
|
1577
|
+
style: t2
|
|
1578
|
+
}), $[6] = t1, $[7] = url, $[8] = t3) : t3 = $[8];
|
|
1579
|
+
let t4;
|
|
1580
|
+
$[9] === caption ? t4 = $[10] : (t4 = isDefined(caption) && /* @__PURE__ */ jsx(Caption, { children: caption }), $[9] = caption, $[10] = t4);
|
|
1581
|
+
let t5;
|
|
1582
|
+
return $[11] !== props || $[12] !== t3 || $[13] !== t4 ? (t5 = /* @__PURE__ */ jsxs("div", {
|
|
1583
|
+
...props,
|
|
1584
|
+
children: [t3, t4]
|
|
1585
|
+
}), $[11] = props, $[12] = t3, $[13] = t4, $[14] = t5) : t5 = $[14], t5;
|
|
1586
|
+
}
|
|
1587
|
+
function ImageBlock(t0) {
|
|
1588
|
+
let $ = c(12), props, style, value;
|
|
1589
|
+
if ($[0] === t0 ? (props = $[1], style = $[2], value = $[3]) : ({value, style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style, $[3] = value), !isDefined(value.asset?.url)) return null;
|
|
1590
|
+
let t1;
|
|
1591
|
+
$[4] === style ? t1 = $[5] : (t1 = {
|
|
1592
|
+
marginBlock: contentSpacing.media,
|
|
1593
|
+
...style
|
|
1594
|
+
}, $[4] = style, $[5] = t1);
|
|
1595
|
+
let t2;
|
|
1596
|
+
return $[6] !== props || $[7] !== t1 || $[8] !== value.alt || $[9] !== value.asset.url || $[10] !== value.caption ? (t2 = /* @__PURE__ */ jsx(ImageContent, {
|
|
1597
|
+
url: value.asset.url,
|
|
1598
|
+
alt: value.alt,
|
|
1599
|
+
caption: value.caption,
|
|
1600
|
+
style: t1,
|
|
1601
|
+
...props
|
|
1602
|
+
}), $[6] = props, $[7] = t1, $[8] = value.alt, $[9] = value.asset.url, $[10] = value.caption, $[11] = t2) : t2 = $[11], t2;
|
|
1603
|
+
}
|
|
1604
|
+
function VideoContent(t0) {
|
|
1605
|
+
let $ = c(16), caption, props, url;
|
|
1606
|
+
$[0] === t0 ? (caption = $[1], props = $[2], url = $[3]) : ({url, caption, ...props} = t0, $[0] = t0, $[1] = caption, $[2] = props, $[3] = url);
|
|
1607
|
+
let t1;
|
|
1608
|
+
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
1609
|
+
display: "block",
|
|
1610
|
+
maxWidth: "100%",
|
|
1611
|
+
borderRadius: 4,
|
|
1612
|
+
WebkitTransform: "translateZ(0)"
|
|
1613
|
+
}, $[4] = t1) : t1 = $[4];
|
|
1614
|
+
let t2 = caption ?? "Video", t3;
|
|
1615
|
+
$[5] === t2 ? t3 = $[6] : (t3 = /* @__PURE__ */ jsx("track", {
|
|
1616
|
+
kind: "captions",
|
|
1617
|
+
label: t2
|
|
1618
|
+
}), $[5] = t2, $[6] = t3);
|
|
1619
|
+
let t4;
|
|
1620
|
+
$[7] !== t3 || $[8] !== url ? (t4 = /* @__PURE__ */ jsx("video", {
|
|
1621
|
+
src: url,
|
|
1622
|
+
controls: !0,
|
|
1623
|
+
style: t1,
|
|
1624
|
+
children: t3
|
|
1625
|
+
}), $[7] = t3, $[8] = url, $[9] = t4) : t4 = $[9];
|
|
1626
|
+
let t5;
|
|
1627
|
+
$[10] === caption ? t5 = $[11] : (t5 = isDefined(caption) && /* @__PURE__ */ jsx(Caption, { children: caption }), $[10] = caption, $[11] = t5);
|
|
1628
|
+
let t6;
|
|
1629
|
+
return $[12] !== props || $[13] !== t4 || $[14] !== t5 ? (t6 = /* @__PURE__ */ jsxs("div", {
|
|
1630
|
+
...props,
|
|
1631
|
+
children: [t4, t5]
|
|
1632
|
+
}), $[12] = props, $[13] = t4, $[14] = t5, $[15] = t6) : t6 = $[15], t6;
|
|
1633
|
+
}
|
|
1634
|
+
function VideoBlock(t0) {
|
|
1635
|
+
let $ = c(11), props, style, value;
|
|
1636
|
+
if ($[0] === t0 ? (props = $[1], style = $[2], value = $[3]) : ({value, style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style, $[3] = value), !isDefined(value.asset?.url)) return null;
|
|
1637
|
+
let t1;
|
|
1638
|
+
$[4] === style ? t1 = $[5] : (t1 = {
|
|
1639
|
+
marginBlock: contentSpacing.media,
|
|
1640
|
+
...style
|
|
1641
|
+
}, $[4] = style, $[5] = t1);
|
|
1642
|
+
let t2;
|
|
2339
1643
|
return $[6] !== props || $[7] !== t1 || $[8] !== value.asset.url || $[9] !== value.caption ? (t2 = /* @__PURE__ */ jsx(VideoContent, {
|
|
2340
1644
|
url: value.asset.url,
|
|
2341
1645
|
caption: value.caption,
|
|
@@ -2343,6 +1647,41 @@ function VideoBlock(t0) {
|
|
|
2343
1647
|
...props
|
|
2344
1648
|
}), $[6] = props, $[7] = t1, $[8] = value.asset.url, $[9] = value.caption, $[10] = t2) : t2 = $[10], t2;
|
|
2345
1649
|
}
|
|
1650
|
+
function PortableBlockquote(t0) {
|
|
1651
|
+
let $ = c(15), children, muted, props, style;
|
|
1652
|
+
$[0] === t0 ? (children = $[1], muted = $[2], props = $[3], style = $[4]) : ({muted, children, style, ...props} = t0, $[0] = t0, $[1] = children, $[2] = muted, $[3] = props, $[4] = style);
|
|
1653
|
+
let t1;
|
|
1654
|
+
$[5] === style ? t1 = $[6] : (t1 = {
|
|
1655
|
+
borderLeft: "2px solid var(--card-border-color)",
|
|
1656
|
+
...style
|
|
1657
|
+
}, $[5] = style, $[6] = t1);
|
|
1658
|
+
let t2;
|
|
1659
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { fontStyle: "italic" }, $[7] = t2) : t2 = $[7];
|
|
1660
|
+
let t3;
|
|
1661
|
+
$[8] !== children || $[9] !== muted ? (t3 = /* @__PURE__ */ jsx(Text, {
|
|
1662
|
+
size: 1,
|
|
1663
|
+
muted,
|
|
1664
|
+
style: t2,
|
|
1665
|
+
children
|
|
1666
|
+
}), $[8] = children, $[9] = muted, $[10] = t3) : t3 = $[10];
|
|
1667
|
+
let t4;
|
|
1668
|
+
return $[11] !== props || $[12] !== t1 || $[13] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, {
|
|
1669
|
+
paddingY: 1,
|
|
1670
|
+
paddingLeft: 3,
|
|
1671
|
+
style: t1,
|
|
1672
|
+
...props,
|
|
1673
|
+
children: t3
|
|
1674
|
+
}), $[11] = props, $[12] = t1, $[13] = t3, $[14] = t4) : t4 = $[14], t4;
|
|
1675
|
+
}
|
|
1676
|
+
function PortableHeading(props) {
|
|
1677
|
+
let $ = c(2), t0;
|
|
1678
|
+
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
|
|
1679
|
+
as: "h2",
|
|
1680
|
+
size: 1,
|
|
1681
|
+
weight: "medium",
|
|
1682
|
+
...props
|
|
1683
|
+
}), $[0] = props, $[1] = t0), t0;
|
|
1684
|
+
}
|
|
2346
1685
|
function PortableList(t0) {
|
|
2347
1686
|
let $ = c(12), props, style, t1;
|
|
2348
1687
|
$[0] === t0 ? (props = $[1], style = $[2], t1 = $[3]) : ({ordered: t1, style, ...props} = t0, $[0] = t0, $[1] = props, $[2] = style, $[3] = t1);
|
|
@@ -2369,19 +1708,25 @@ function PortableList(t0) {
|
|
|
2369
1708
|
...props
|
|
2370
1709
|
}), $[9] = listStyle, $[10] = props, $[11] = t3) : t3 = $[11], t3;
|
|
2371
1710
|
}
|
|
1711
|
+
function PortableParagraph(props) {
|
|
1712
|
+
let $ = c(2), t0;
|
|
1713
|
+
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
|
|
1714
|
+
size: 1,
|
|
1715
|
+
...props
|
|
1716
|
+
}), $[0] = props, $[1] = t0), t0;
|
|
1717
|
+
}
|
|
2372
1718
|
/**
|
|
2373
|
-
*
|
|
1719
|
+
* Works out the vertical space around a list, which is smaller for nested lists.
|
|
2374
1720
|
*
|
|
2375
|
-
* @param level - Nesting depth
|
|
2376
|
-
* @returns The
|
|
1721
|
+
* @param level - Nesting depth, starting at 1.
|
|
1722
|
+
* @returns The space in pixels.
|
|
2377
1723
|
*/
|
|
2378
1724
|
function listSpacing(level) {
|
|
2379
1725
|
return level > 1 ? contentSpacing.nestedList : contentSpacing.list;
|
|
2380
1726
|
}
|
|
2381
1727
|
/**
|
|
2382
|
-
*
|
|
2383
|
-
*
|
|
2384
|
-
* as the surrounding text.
|
|
1728
|
+
* Components for each block style, mark, and embedded type in a guide. Marks and list items not listed
|
|
1729
|
+
* here are left to the library's defaults on purpose.
|
|
2385
1730
|
*/
|
|
2386
1731
|
const components = {
|
|
2387
1732
|
block: {
|
|
@@ -2427,10 +1772,10 @@ const components = {
|
|
|
2427
1772
|
}
|
|
2428
1773
|
};
|
|
2429
1774
|
/**
|
|
2430
|
-
*
|
|
2431
|
-
*
|
|
1775
|
+
* Wraps a block component for Portable Text, passing only the block's value. Otherwise the library's
|
|
1776
|
+
* other props would reach the DOM.
|
|
2432
1777
|
*
|
|
2433
|
-
* @param Component -
|
|
1778
|
+
* @param Component - The block component.
|
|
2434
1779
|
* @returns A component Portable Text can render the type with.
|
|
2435
1780
|
*/
|
|
2436
1781
|
function blockRenderer(Component) {
|
|
@@ -2479,11 +1824,36 @@ function PortableText$1(t0) {
|
|
|
2479
1824
|
children: t7
|
|
2480
1825
|
}), $[15] = props, $[16] = t7, $[17] = t8) : t8 = $[17], t8;
|
|
2481
1826
|
}
|
|
1827
|
+
function BookOpenTextIcon(props) {
|
|
1828
|
+
let $ = c(8), t0, t1, t2, t3, t4, t5;
|
|
1829
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M12 7v14" }), t1 = /* @__PURE__ */ jsx("path", { d: "M16 12h2" }), t2 = /* @__PURE__ */ jsx("path", { d: "M16 8h2" }), t3 = /* @__PURE__ */ jsx("path", { d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z" }), t4 = /* @__PURE__ */ jsx("path", { d: "M6 12h2" }), t5 = /* @__PURE__ */ jsx("path", { d: "M6 8h2" }), $[0] = t0, $[1] = t1, $[2] = t2, $[3] = t3, $[4] = t4, $[5] = t5) : (t0 = $[0], t1 = $[1], t2 = $[2], t3 = $[3], t4 = $[4], t5 = $[5]);
|
|
1830
|
+
let t6;
|
|
1831
|
+
return $[6] === props ? t6 = $[7] : (t6 = /* @__PURE__ */ jsxs("svg", {
|
|
1832
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1833
|
+
width: 24,
|
|
1834
|
+
height: 24,
|
|
1835
|
+
viewBox: "0 0 24 24",
|
|
1836
|
+
fill: "none",
|
|
1837
|
+
stroke: "currentColor",
|
|
1838
|
+
strokeWidth: 2,
|
|
1839
|
+
strokeLinecap: "round",
|
|
1840
|
+
strokeLinejoin: "round",
|
|
1841
|
+
...props,
|
|
1842
|
+
children: [
|
|
1843
|
+
t0,
|
|
1844
|
+
t1,
|
|
1845
|
+
t2,
|
|
1846
|
+
t3,
|
|
1847
|
+
t4,
|
|
1848
|
+
t5
|
|
1849
|
+
]
|
|
1850
|
+
}), $[6] = props, $[7] = t6), t6;
|
|
1851
|
+
}
|
|
2482
1852
|
/**
|
|
2483
|
-
* Builds a section for each guide group
|
|
1853
|
+
* Builds a sidebar section for each guide group.
|
|
2484
1854
|
*
|
|
2485
|
-
* @param handbook - Handbook
|
|
2486
|
-
* @returns One section per group,
|
|
1855
|
+
* @param handbook - The Handbook document.
|
|
1856
|
+
* @returns One section per group, with an entry per guide.
|
|
2487
1857
|
*/
|
|
2488
1858
|
function guidesSections(handbook) {
|
|
2489
1859
|
return handbook.groups.map(({ title, guides }) => ({
|
|
@@ -2498,9 +1868,9 @@ function guidesSections(handbook) {
|
|
|
2498
1868
|
}));
|
|
2499
1869
|
}
|
|
2500
1870
|
/**
|
|
2501
|
-
*
|
|
1871
|
+
* Lists every page in the Handbook, in sidebar order.
|
|
2502
1872
|
*
|
|
2503
|
-
* @returns
|
|
1873
|
+
* @returns The built-in pages, the configured document roles, and the guide groups, as sections.
|
|
2504
1874
|
*/
|
|
2505
1875
|
function useSections() {
|
|
2506
1876
|
let $ = c(4), { roles, handbook, loading } = useHandbookContext(), t0;
|
|
@@ -2518,7 +1888,7 @@ function Content(props) {
|
|
|
2518
1888
|
let { id } = t6;
|
|
2519
1889
|
return id === activeTab;
|
|
2520
1890
|
}, $[9] = activeTab, $[10] = t5);
|
|
2521
|
-
let entry = sections.flatMap(_temp$
|
|
1891
|
+
let entry = sections.flatMap(_temp$2).find(t5);
|
|
2522
1892
|
T0 = Pane, t0 = "handbook-content", t1 = 2.5, t2 = 320, t3 = props, t4 = isDefined(entry) && /* @__PURE__ */ jsx(ContentPanel, {
|
|
2523
1893
|
id: entry.id,
|
|
2524
1894
|
title: entry.title,
|
|
@@ -2535,7 +1905,7 @@ function Content(props) {
|
|
|
2535
1905
|
children: t4
|
|
2536
1906
|
}), $[11] = T0, $[12] = t0, $[13] = t1, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5) : t5 = $[17], t5;
|
|
2537
1907
|
}
|
|
2538
|
-
function _temp$
|
|
1908
|
+
function _temp$2(section) {
|
|
2539
1909
|
return section.entries;
|
|
2540
1910
|
}
|
|
2541
1911
|
function SidebarHeading(t0) {
|
|
@@ -2614,9 +1984,16 @@ function SidebarTab(t0) {
|
|
|
2614
1984
|
children: t6
|
|
2615
1985
|
}), $[17] = id, $[18] = props, $[19] = selected, $[20] = t1, $[21] = t2, $[22] = t3, $[23] = t6, $[24] = t7) : t7 = $[24], t7;
|
|
2616
1986
|
}
|
|
1987
|
+
function renderItem(item) {
|
|
1988
|
+
return item.type === "heading" ? /* @__PURE__ */ jsx(SidebarHeading, { title: item.title }) : /* @__PURE__ */ jsx(SidebarTab, {
|
|
1989
|
+
id: item.id,
|
|
1990
|
+
label: item.label,
|
|
1991
|
+
icon: item.icon
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
2617
1994
|
function Sidebar(props) {
|
|
2618
1995
|
let $ = c(14), { sidebarTitle } = useHandbookContext(), sections = useSections(), t0;
|
|
2619
|
-
$[0] === sections ? t0 = $[1] : (t0 = sections.flatMap(_temp2), $[0] = sections, $[1] = t0);
|
|
1996
|
+
$[0] === sections ? t0 = $[1] : (t0 = sections.flatMap(_temp2$1), $[0] = sections, $[1] = t0);
|
|
2620
1997
|
let items = t0, t1;
|
|
2621
1998
|
$[2] === items ? t1 = $[3] : (t1 = function getItemDisabled(virtualIndex) {
|
|
2622
1999
|
return items[virtualIndex]?.type === "heading";
|
|
@@ -2636,7 +2013,7 @@ function Sidebar(props) {
|
|
|
2636
2013
|
onlyShowSelectionWhenActive: !0,
|
|
2637
2014
|
paddingBottom: 1,
|
|
2638
2015
|
paddingX: 3,
|
|
2639
|
-
renderItem
|
|
2016
|
+
renderItem,
|
|
2640
2017
|
wrapAround: !1
|
|
2641
2018
|
})
|
|
2642
2019
|
}), $[6] = getItemDisabled, $[7] = items, $[8] = sidebarTitle, $[9] = t3) : t3 = $[9];
|
|
@@ -2650,21 +2027,14 @@ function Sidebar(props) {
|
|
|
2650
2027
|
children: [t2, t3]
|
|
2651
2028
|
}), $[10] = props, $[11] = t2, $[12] = t3, $[13] = t4) : t4 = $[13], t4;
|
|
2652
2029
|
}
|
|
2653
|
-
function
|
|
2654
|
-
return item.type === "heading" ? /* @__PURE__ */ jsx(SidebarHeading, { title: item.title }) : /* @__PURE__ */ jsx(SidebarTab, {
|
|
2655
|
-
id: item.id,
|
|
2656
|
-
label: item.label,
|
|
2657
|
-
icon: item.icon
|
|
2658
|
-
});
|
|
2659
|
-
}
|
|
2660
|
-
function _temp2(t0) {
|
|
2030
|
+
function _temp2$1(t0) {
|
|
2661
2031
|
let { title, entries } = t0;
|
|
2662
2032
|
return [{
|
|
2663
2033
|
type: "heading",
|
|
2664
2034
|
title
|
|
2665
|
-
}, ...entries.map(_temp)];
|
|
2035
|
+
}, ...entries.map(_temp$1)];
|
|
2666
2036
|
}
|
|
2667
|
-
function _temp(entry) {
|
|
2037
|
+
function _temp$1(entry) {
|
|
2668
2038
|
return {
|
|
2669
2039
|
type: "tab",
|
|
2670
2040
|
id: entry.id,
|
|
@@ -2719,47 +2089,722 @@ function HandbookTool(t0) {
|
|
|
2719
2089
|
children: t7
|
|
2720
2090
|
}), $[7] = options, $[8] = t7, $[9] = t8) : t8 = $[9], t8;
|
|
2721
2091
|
}
|
|
2722
|
-
/** Editors the plugin
|
|
2092
|
+
/** Editors from the plugin configuration, so the structure helper doesn't need them passed again. */
|
|
2723
2093
|
let configuredEditors;
|
|
2724
2094
|
/**
|
|
2725
|
-
*
|
|
2726
|
-
*
|
|
2095
|
+
* Stores the editors from the plugin configuration. A Studio with several workspaces keeps only the last
|
|
2096
|
+
* workspace's list, so pass the list explicitly there.
|
|
2727
2097
|
*
|
|
2728
|
-
* @param editors - Email addresses
|
|
2098
|
+
* @param editors - Email addresses of the editors.
|
|
2729
2099
|
*/
|
|
2730
2100
|
function setConfiguredEditors(editors) {
|
|
2731
2101
|
configuredEditors = editors;
|
|
2732
2102
|
}
|
|
2733
2103
|
/**
|
|
2734
|
-
* Checks whether an email address
|
|
2104
|
+
* Checks whether an email address belongs to an editor. Without an editors list, everyone is an editor.
|
|
2735
2105
|
*
|
|
2736
|
-
* @param editors - Email addresses
|
|
2106
|
+
* @param editors - Email addresses of the editors, defaulting to the configured list.
|
|
2737
2107
|
* @param email - The email address to check.
|
|
2738
|
-
* @returns Whether the
|
|
2108
|
+
* @returns Whether the address belongs to an editor.
|
|
2739
2109
|
*/
|
|
2740
2110
|
function isPermittedEditor(editors, email) {
|
|
2741
2111
|
let permitted = editors ?? configuredEditors;
|
|
2742
2112
|
return isDefined(permitted) ? isDefined(email) ? permitted.includes(email) : !1 : !0;
|
|
2743
2113
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2114
|
+
function CalloutPreview(t0) {
|
|
2115
|
+
let $ = c(7), { variant, body } = t0, t1 = variant ?? "tip", t2;
|
|
2116
|
+
$[0] === body ? t2 = $[1] : (t2 = body?.map(_temp2), $[0] = body, $[1] = t2);
|
|
2117
|
+
let t3;
|
|
2118
|
+
$[2] === t2 ? t3 = $[3] : (t3 = /* @__PURE__ */ jsx(Stack, {
|
|
2119
|
+
gap: 3,
|
|
2120
|
+
children: t2
|
|
2121
|
+
}), $[2] = t2, $[3] = t3);
|
|
2122
|
+
let t4;
|
|
2123
|
+
return $[4] !== t1 || $[5] !== t3 ? (t4 = /* @__PURE__ */ jsx(CalloutContent, {
|
|
2124
|
+
variant: t1,
|
|
2125
|
+
children: t3
|
|
2126
|
+
}), $[4] = t1, $[5] = t3, $[6] = t4) : t4 = $[6], t4;
|
|
2127
|
+
}
|
|
2128
|
+
function _temp2(t0) {
|
|
2129
|
+
let { _key, children } = t0;
|
|
2130
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2131
|
+
style: { whiteSpace: "pre-wrap" },
|
|
2132
|
+
children: children.map(_temp).join("")
|
|
2133
|
+
}, _key);
|
|
2134
|
+
}
|
|
2135
|
+
function _temp(child) {
|
|
2136
|
+
return child.text;
|
|
2137
|
+
}
|
|
2138
|
+
function CodeDecorator(t0) {
|
|
2139
|
+
let $ = c(2), { children } = t0, t1;
|
|
2140
|
+
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableCode, { children }), $[0] = children, $[1] = t1), t1;
|
|
2141
|
+
}
|
|
2142
|
+
function ParagraphStyle(t0) {
|
|
2143
|
+
let $ = c(2), { children } = t0, t1;
|
|
2144
|
+
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableParagraph, { children }), $[0] = children, $[1] = t1), t1;
|
|
2145
|
+
}
|
|
2146
|
+
function HeadingStyle(t0) {
|
|
2147
|
+
let $ = c(2), { children } = t0, t1;
|
|
2148
|
+
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableHeading, { children }), $[0] = children, $[1] = t1), t1;
|
|
2149
|
+
}
|
|
2150
|
+
function BlockquoteStyle(t0) {
|
|
2151
|
+
let $ = c(2), { children } = t0, t1;
|
|
2152
|
+
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(PortableBlockquote, { children }), $[0] = children, $[1] = t1), t1;
|
|
2153
|
+
}
|
|
2154
|
+
function MessageCircleIcon(props) {
|
|
2155
|
+
let $ = c(3), t0;
|
|
2156
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" }), $[0] = t0) : t0 = $[0];
|
|
2157
|
+
let t1;
|
|
2158
|
+
return $[1] === props ? t1 = $[2] : (t1 = /* @__PURE__ */ jsx("svg", {
|
|
2159
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2160
|
+
width: 24,
|
|
2161
|
+
height: 24,
|
|
2162
|
+
viewBox: "0 0 24 24",
|
|
2163
|
+
fill: "none",
|
|
2164
|
+
stroke: "currentColor",
|
|
2165
|
+
strokeWidth: 2,
|
|
2166
|
+
strokeLinecap: "round",
|
|
2167
|
+
strokeLinejoin: "round",
|
|
2168
|
+
...props,
|
|
2169
|
+
children: t0
|
|
2170
|
+
}), $[1] = props, $[2] = t1), t1;
|
|
2171
|
+
}
|
|
2172
|
+
function LinkIcon(props) {
|
|
2173
|
+
let $ = c(4), t0, t1;
|
|
2174
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), t1 = /* @__PURE__ */ jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }), $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]);
|
|
2175
|
+
let t2;
|
|
2176
|
+
return $[2] === props ? t2 = $[3] : (t2 = /* @__PURE__ */ jsxs("svg", {
|
|
2177
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2178
|
+
width: 24,
|
|
2179
|
+
height: 24,
|
|
2180
|
+
viewBox: "0 0 24 24",
|
|
2181
|
+
fill: "none",
|
|
2182
|
+
stroke: "currentColor",
|
|
2183
|
+
strokeWidth: 2,
|
|
2184
|
+
strokeLinecap: "round",
|
|
2185
|
+
strokeLinejoin: "round",
|
|
2186
|
+
...props,
|
|
2187
|
+
children: [t0, t1]
|
|
2188
|
+
}), $[2] = props, $[3] = t2), t2;
|
|
2189
|
+
}
|
|
2190
|
+
const linkAnnotation = defineArrayMember({
|
|
2191
|
+
name: "link",
|
|
2192
|
+
type: "object",
|
|
2193
|
+
description: "Link applied to the selected text.",
|
|
2194
|
+
icon: createSanityIcon(LinkIcon),
|
|
2195
|
+
preview: {
|
|
2196
|
+
select: { href: "href" },
|
|
2197
|
+
prepare(selection) {
|
|
2198
|
+
let { href } = selection;
|
|
2199
|
+
return { title: href ?? "Link" };
|
|
2200
|
+
}
|
|
2201
|
+
},
|
|
2202
|
+
fields: [defineField({
|
|
2203
|
+
name: "href",
|
|
2204
|
+
type: "url",
|
|
2205
|
+
title: "URL",
|
|
2206
|
+
description: "Web address to link to. Use http, https, mailto, or tel.",
|
|
2207
|
+
validation: (rule) => rule.uri({ scheme: [
|
|
2208
|
+
"http",
|
|
2209
|
+
"https",
|
|
2210
|
+
"mailto",
|
|
2211
|
+
"tel"
|
|
2212
|
+
] })
|
|
2213
|
+
})]
|
|
2214
|
+
}), calloutType = defineType({
|
|
2215
|
+
name: calloutTypeName,
|
|
2216
|
+
type: "object",
|
|
2217
|
+
title: "Callout",
|
|
2218
|
+
description: "Highlighted tip, note, or warning.",
|
|
2219
|
+
icon: createSanityIcon(MessageCircleIcon),
|
|
2220
|
+
components: { preview: CalloutPreview },
|
|
2221
|
+
preview: {
|
|
2222
|
+
select: {
|
|
2223
|
+
variant: "variant",
|
|
2224
|
+
body: "body"
|
|
2225
|
+
},
|
|
2226
|
+
prepare(selection) {
|
|
2227
|
+
let { variant, body } = selection;
|
|
2228
|
+
return {
|
|
2229
|
+
title: "Callout",
|
|
2230
|
+
variant,
|
|
2231
|
+
body
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
},
|
|
2235
|
+
fields: [defineField({
|
|
2236
|
+
name: "variant",
|
|
2237
|
+
type: "string",
|
|
2238
|
+
description: "Kind of callout, which sets its icon and color.",
|
|
2239
|
+
initialValue: "tip",
|
|
2240
|
+
validation: (rule) => rule.required(),
|
|
2241
|
+
options: {
|
|
2242
|
+
list: [
|
|
2243
|
+
{
|
|
2244
|
+
title: "Tip",
|
|
2245
|
+
value: "tip"
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
title: "Information",
|
|
2249
|
+
value: "info"
|
|
2250
|
+
},
|
|
2251
|
+
{
|
|
2252
|
+
title: "Warning",
|
|
2253
|
+
value: "warning"
|
|
2254
|
+
}
|
|
2255
|
+
],
|
|
2256
|
+
layout: "radio",
|
|
2257
|
+
direction: "horizontal"
|
|
2258
|
+
}
|
|
2259
|
+
}), defineField({
|
|
2260
|
+
name: "body",
|
|
2261
|
+
type: "array",
|
|
2262
|
+
description: "Text inside the callout, with inline formatting and links.",
|
|
2263
|
+
of: [defineArrayMember({
|
|
2264
|
+
name: "block",
|
|
2265
|
+
type: "block",
|
|
2266
|
+
styles: [{
|
|
2267
|
+
title: "Normal",
|
|
2268
|
+
value: "normal",
|
|
2269
|
+
component: ParagraphStyle
|
|
2270
|
+
}],
|
|
2271
|
+
lists: [],
|
|
2272
|
+
marks: {
|
|
2273
|
+
decorators: [
|
|
2274
|
+
{
|
|
2275
|
+
title: "Bold",
|
|
2276
|
+
value: "strong"
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
title: "Italic",
|
|
2280
|
+
value: "em"
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
title: "Strikethrough",
|
|
2284
|
+
value: "strike-through"
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
title: "Code",
|
|
2288
|
+
value: "code",
|
|
2289
|
+
component: CodeDecorator
|
|
2290
|
+
}
|
|
2291
|
+
],
|
|
2292
|
+
annotations: [linkAnnotation]
|
|
2293
|
+
}
|
|
2294
|
+
})]
|
|
2295
|
+
})]
|
|
2296
|
+
});
|
|
2297
|
+
function CodePreview(t0) {
|
|
2298
|
+
let $ = c(3), { code, language } = t0;
|
|
2299
|
+
if (!isDefined(code)) return null;
|
|
2300
|
+
let t1;
|
|
2301
|
+
return $[0] !== code || $[1] !== language ? (t1 = /* @__PURE__ */ jsx(CodeContent, {
|
|
2302
|
+
code,
|
|
2303
|
+
language
|
|
2304
|
+
}), $[0] = code, $[1] = language, $[2] = t1) : t1 = $[2], t1;
|
|
2305
|
+
}
|
|
2306
|
+
function CodeIcon(props) {
|
|
2307
|
+
let $ = c(4), t0, t1;
|
|
2308
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "m16 18 6-6-6-6" }), t1 = /* @__PURE__ */ jsx("path", { d: "m8 6-6 6 6 6" }), $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]);
|
|
2309
|
+
let t2;
|
|
2310
|
+
return $[2] === props ? t2 = $[3] : (t2 = /* @__PURE__ */ jsxs("svg", {
|
|
2311
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2312
|
+
width: 24,
|
|
2313
|
+
height: 24,
|
|
2314
|
+
viewBox: "0 0 24 24",
|
|
2315
|
+
fill: "none",
|
|
2316
|
+
stroke: "currentColor",
|
|
2317
|
+
strokeWidth: 2,
|
|
2318
|
+
strokeLinecap: "round",
|
|
2319
|
+
strokeLinejoin: "round",
|
|
2320
|
+
...props,
|
|
2321
|
+
children: [t0, t1]
|
|
2322
|
+
}), $[2] = props, $[3] = t2), t2;
|
|
2323
|
+
}
|
|
2324
|
+
const codeType = defineType({
|
|
2325
|
+
name: codeTypeName,
|
|
2326
|
+
type: "object",
|
|
2327
|
+
title: "Code",
|
|
2328
|
+
description: "Code block with syntax highlighting.",
|
|
2329
|
+
icon: createSanityIcon(CodeIcon),
|
|
2330
|
+
components: { preview: CodePreview },
|
|
2331
|
+
preview: { select: {
|
|
2332
|
+
code: "code",
|
|
2333
|
+
language: "language"
|
|
2334
|
+
} },
|
|
2335
|
+
fields: [defineField({
|
|
2336
|
+
name: "code",
|
|
2337
|
+
type: "text",
|
|
2338
|
+
description: "Code to display."
|
|
2339
|
+
}), defineField({
|
|
2340
|
+
name: "language",
|
|
2341
|
+
type: "string",
|
|
2342
|
+
description: "Language used for syntax highlighting.",
|
|
2343
|
+
options: { list: [
|
|
2344
|
+
{
|
|
2345
|
+
title: "CSS",
|
|
2346
|
+
value: "css"
|
|
2347
|
+
},
|
|
2348
|
+
{
|
|
2349
|
+
title: "GROQ",
|
|
2350
|
+
value: "groq"
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
title: "HTML",
|
|
2354
|
+
value: "html"
|
|
2355
|
+
},
|
|
2356
|
+
{
|
|
2357
|
+
title: "JavaScript",
|
|
2358
|
+
value: "javascript"
|
|
2359
|
+
},
|
|
2360
|
+
{
|
|
2361
|
+
title: "JSON",
|
|
2362
|
+
value: "json"
|
|
2363
|
+
},
|
|
2364
|
+
{
|
|
2365
|
+
title: "Plain Text",
|
|
2366
|
+
value: "text"
|
|
2367
|
+
},
|
|
2368
|
+
{
|
|
2369
|
+
title: "React",
|
|
2370
|
+
value: "tsx"
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
title: "Shell",
|
|
2374
|
+
value: "shell"
|
|
2375
|
+
},
|
|
2376
|
+
{
|
|
2377
|
+
title: "TypeScript",
|
|
2378
|
+
value: "typescript"
|
|
2379
|
+
}
|
|
2380
|
+
] }
|
|
2381
|
+
})]
|
|
2382
|
+
});
|
|
2383
|
+
function HorizontalRulePreview(_props) {
|
|
2384
|
+
let $ = c(1), t0;
|
|
2385
|
+
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(HorizontalRuleContent, { style: { marginBlock: 8 } }), $[0] = t0) : t0 = $[0], t0;
|
|
2386
|
+
}
|
|
2387
|
+
function SeparatorHorizontalIcon(props) {
|
|
2388
|
+
let $ = c(5), t0, t1, t2;
|
|
2389
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "m16 16-4 4-4-4" }), t1 = /* @__PURE__ */ jsx("path", { d: "M3 12h18" }), t2 = /* @__PURE__ */ jsx("path", { d: "m8 8 4-4 4 4" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
2390
|
+
let t3;
|
|
2391
|
+
return $[3] === props ? t3 = $[4] : (t3 = /* @__PURE__ */ jsxs("svg", {
|
|
2392
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2393
|
+
width: 24,
|
|
2394
|
+
height: 24,
|
|
2395
|
+
viewBox: "0 0 24 24",
|
|
2396
|
+
fill: "none",
|
|
2397
|
+
stroke: "currentColor",
|
|
2398
|
+
strokeWidth: 2,
|
|
2399
|
+
strokeLinecap: "round",
|
|
2400
|
+
strokeLinejoin: "round",
|
|
2401
|
+
...props,
|
|
2402
|
+
children: [
|
|
2403
|
+
t0,
|
|
2404
|
+
t1,
|
|
2405
|
+
t2
|
|
2406
|
+
]
|
|
2407
|
+
}), $[3] = props, $[4] = t3), t3;
|
|
2408
|
+
}
|
|
2409
|
+
const horizontalRuleType = defineType({
|
|
2410
|
+
name: horizontalRuleTypeName,
|
|
2411
|
+
type: "object",
|
|
2412
|
+
title: "Horizontal Rule",
|
|
2413
|
+
description: "Divider between sections.",
|
|
2414
|
+
icon: createSanityIcon(SeparatorHorizontalIcon),
|
|
2415
|
+
components: { preview: HorizontalRulePreview },
|
|
2416
|
+
preview: { prepare() {
|
|
2417
|
+
return { title: "Horizontal Rule" };
|
|
2418
|
+
} },
|
|
2419
|
+
fields: [defineField({
|
|
2420
|
+
name: "style",
|
|
2421
|
+
type: "string",
|
|
2422
|
+
description: "Unused placeholder field.",
|
|
2423
|
+
hidden: !0
|
|
2424
|
+
})]
|
|
2425
|
+
});
|
|
2426
|
+
function ImagePreview(t0) {
|
|
2427
|
+
let $ = c(5), { url, alt, caption } = t0;
|
|
2428
|
+
if (!isDefined(url)) return null;
|
|
2429
|
+
let t1;
|
|
2430
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = { padding: 8 }, $[0] = t1) : t1 = $[0];
|
|
2431
|
+
let t2;
|
|
2432
|
+
return $[1] !== alt || $[2] !== caption || $[3] !== url ? (t2 = /* @__PURE__ */ jsx(ImageContent, {
|
|
2433
|
+
url,
|
|
2434
|
+
alt,
|
|
2435
|
+
caption,
|
|
2436
|
+
style: t1
|
|
2437
|
+
}), $[1] = alt, $[2] = caption, $[3] = url, $[4] = t2) : t2 = $[4], t2;
|
|
2438
|
+
}
|
|
2439
|
+
function ImageIcon(props) {
|
|
2440
|
+
let $ = c(5), t0, t1, t2;
|
|
2441
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("rect", {
|
|
2442
|
+
width: "18",
|
|
2443
|
+
height: "18",
|
|
2444
|
+
x: "3",
|
|
2445
|
+
y: "3",
|
|
2446
|
+
rx: "2",
|
|
2447
|
+
ry: "2"
|
|
2448
|
+
}), t1 = /* @__PURE__ */ jsx("circle", {
|
|
2449
|
+
cx: "9",
|
|
2450
|
+
cy: "9",
|
|
2451
|
+
r: "2"
|
|
2452
|
+
}), t2 = /* @__PURE__ */ jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
|
|
2453
|
+
let t3;
|
|
2454
|
+
return $[3] === props ? t3 = $[4] : (t3 = /* @__PURE__ */ jsxs("svg", {
|
|
2455
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2456
|
+
width: 24,
|
|
2457
|
+
height: 24,
|
|
2458
|
+
viewBox: "0 0 24 24",
|
|
2459
|
+
fill: "none",
|
|
2460
|
+
stroke: "currentColor",
|
|
2461
|
+
strokeWidth: 2,
|
|
2462
|
+
strokeLinecap: "round",
|
|
2463
|
+
strokeLinejoin: "round",
|
|
2464
|
+
...props,
|
|
2465
|
+
children: [
|
|
2466
|
+
t0,
|
|
2467
|
+
t1,
|
|
2468
|
+
t2
|
|
2469
|
+
]
|
|
2470
|
+
}), $[3] = props, $[4] = t3), t3;
|
|
2471
|
+
}
|
|
2472
|
+
const imageType = defineType({
|
|
2473
|
+
name: imageTypeName,
|
|
2474
|
+
type: "object",
|
|
2475
|
+
title: "Image",
|
|
2476
|
+
description: "Image with an optional caption and alternative text.",
|
|
2477
|
+
icon: createSanityIcon(ImageIcon),
|
|
2478
|
+
components: { preview: ImagePreview },
|
|
2479
|
+
preview: { select: {
|
|
2480
|
+
caption: "caption",
|
|
2481
|
+
alt: "alt",
|
|
2482
|
+
url: "asset.asset.url"
|
|
2483
|
+
} },
|
|
2484
|
+
fields: [
|
|
2485
|
+
defineField({
|
|
2486
|
+
name: "asset",
|
|
2487
|
+
type: "image",
|
|
2488
|
+
title: "Image",
|
|
2489
|
+
description: "Image to show.",
|
|
2490
|
+
options: { hotspot: !0 }
|
|
2491
|
+
}),
|
|
2492
|
+
defineField({
|
|
2493
|
+
name: "caption",
|
|
2494
|
+
type: "string",
|
|
2495
|
+
description: "Text shown below the image, such as a credit."
|
|
2496
|
+
}),
|
|
2497
|
+
defineField({
|
|
2498
|
+
name: "alt",
|
|
2499
|
+
type: "string",
|
|
2500
|
+
title: "Alternative Text",
|
|
2501
|
+
description: "Description of the image for people who can't see it. Don't repeat the caption."
|
|
2502
|
+
})
|
|
2503
|
+
]
|
|
2504
|
+
});
|
|
2505
|
+
function VideoPreview(t0) {
|
|
2506
|
+
let $ = c(4), { url, caption } = t0;
|
|
2507
|
+
if (!isDefined(url)) return null;
|
|
2508
|
+
let t1;
|
|
2509
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = { padding: 8 }, $[0] = t1) : t1 = $[0];
|
|
2510
|
+
let t2;
|
|
2511
|
+
return $[1] !== caption || $[2] !== url ? (t2 = /* @__PURE__ */ jsx(VideoContent, {
|
|
2512
|
+
url,
|
|
2513
|
+
caption,
|
|
2514
|
+
style: t1
|
|
2515
|
+
}), $[1] = caption, $[2] = url, $[3] = t2) : t2 = $[3], t2;
|
|
2516
|
+
}
|
|
2517
|
+
function FilmIcon(props) {
|
|
2518
|
+
let $ = c(10), t0, t1, t2, t3, t4, t5, t6, t7;
|
|
2519
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("rect", {
|
|
2520
|
+
x: "3",
|
|
2521
|
+
y: "3",
|
|
2522
|
+
width: "18",
|
|
2523
|
+
height: "18",
|
|
2524
|
+
rx: "2"
|
|
2525
|
+
}), t1 = /* @__PURE__ */ jsx("path", { d: "M7 3v18" }), t2 = /* @__PURE__ */ jsx("path", { d: "M3 7.5h4" }), t3 = /* @__PURE__ */ jsx("path", { d: "M3 12h18" }), t4 = /* @__PURE__ */ jsx("path", { d: "M3 16.5h4" }), t5 = /* @__PURE__ */ jsx("path", { d: "M17 3v18" }), t6 = /* @__PURE__ */ jsx("path", { d: "M17 7.5h4" }), t7 = /* @__PURE__ */ jsx("path", { d: "M17 16.5h4" }), $[0] = t0, $[1] = t1, $[2] = t2, $[3] = t3, $[4] = t4, $[5] = t5, $[6] = t6, $[7] = t7) : (t0 = $[0], t1 = $[1], t2 = $[2], t3 = $[3], t4 = $[4], t5 = $[5], t6 = $[6], t7 = $[7]);
|
|
2526
|
+
let t8;
|
|
2527
|
+
return $[8] === props ? t8 = $[9] : (t8 = /* @__PURE__ */ jsxs("svg", {
|
|
2528
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2529
|
+
width: 24,
|
|
2530
|
+
height: 24,
|
|
2531
|
+
viewBox: "0 0 24 24",
|
|
2532
|
+
fill: "none",
|
|
2533
|
+
stroke: "currentColor",
|
|
2534
|
+
strokeWidth: 2,
|
|
2535
|
+
strokeLinecap: "round",
|
|
2536
|
+
strokeLinejoin: "round",
|
|
2537
|
+
...props,
|
|
2538
|
+
children: [
|
|
2539
|
+
t0,
|
|
2540
|
+
t1,
|
|
2541
|
+
t2,
|
|
2542
|
+
t3,
|
|
2543
|
+
t4,
|
|
2544
|
+
t5,
|
|
2545
|
+
t6,
|
|
2546
|
+
t7
|
|
2547
|
+
]
|
|
2548
|
+
}), $[8] = props, $[9] = t8), t8;
|
|
2549
|
+
}
|
|
2550
|
+
const videoType = defineType({
|
|
2551
|
+
name: videoTypeName,
|
|
2552
|
+
type: "object",
|
|
2553
|
+
title: "Video",
|
|
2554
|
+
description: "Video with an optional caption.",
|
|
2555
|
+
icon: createSanityIcon(FilmIcon),
|
|
2556
|
+
components: { preview: VideoPreview },
|
|
2557
|
+
preview: { select: {
|
|
2558
|
+
caption: "caption",
|
|
2559
|
+
url: "asset.asset.url"
|
|
2560
|
+
} },
|
|
2561
|
+
fields: [defineField({
|
|
2562
|
+
name: "asset",
|
|
2563
|
+
type: "file",
|
|
2564
|
+
title: "Video",
|
|
2565
|
+
description: "Video to show.",
|
|
2566
|
+
options: { accept: "video/*" }
|
|
2567
|
+
}), defineField({
|
|
2568
|
+
name: "caption",
|
|
2569
|
+
type: "string",
|
|
2570
|
+
description: "Text shown below the video, such as a credit."
|
|
2571
|
+
})]
|
|
2572
|
+
});
|
|
2573
|
+
function ListItemStyle(t0) {
|
|
2574
|
+
let $ = c(3), { children } = t0, t1;
|
|
2575
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = { marginTop: "0.375em" }, $[0] = t1) : t1 = $[0];
|
|
2576
|
+
let t2;
|
|
2577
|
+
return $[1] === children ? t2 = $[2] : (t2 = /* @__PURE__ */ jsx(Text, {
|
|
2578
|
+
size: 1,
|
|
2579
|
+
style: t1,
|
|
2580
|
+
children
|
|
2581
|
+
}), $[1] = children, $[2] = t2), t2;
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Creates the guide content field, offering the built-in blocks and any custom ones.
|
|
2585
|
+
*
|
|
2586
|
+
* @param customBlocks - Custom blocks added by the site.
|
|
2587
|
+
* @returns The content field.
|
|
2588
|
+
*/
|
|
2589
|
+
function createGuideContentField(customBlocks = []) {
|
|
2590
|
+
return defineField({
|
|
2591
|
+
name: "content",
|
|
2592
|
+
type: "array",
|
|
2593
|
+
description: "Rich text with formatting, headings, lists, images, code blocks, and custom blocks.",
|
|
2594
|
+
of: [
|
|
2595
|
+
defineArrayMember({
|
|
2596
|
+
name: "block",
|
|
2597
|
+
type: "block",
|
|
2598
|
+
styles: [
|
|
2599
|
+
{
|
|
2600
|
+
title: "Paragraph",
|
|
2601
|
+
value: "normal",
|
|
2602
|
+
component: ParagraphStyle
|
|
2603
|
+
},
|
|
2604
|
+
{
|
|
2605
|
+
title: "Heading",
|
|
2606
|
+
value: "h2",
|
|
2607
|
+
component: HeadingStyle
|
|
2608
|
+
},
|
|
2609
|
+
{
|
|
2610
|
+
title: "Blockquote",
|
|
2611
|
+
value: "blockquote",
|
|
2612
|
+
component: BlockquoteStyle
|
|
2613
|
+
}
|
|
2614
|
+
],
|
|
2615
|
+
lists: [{
|
|
2616
|
+
title: "Bullet",
|
|
2617
|
+
value: "bullet",
|
|
2618
|
+
component: ListItemStyle
|
|
2619
|
+
}, {
|
|
2620
|
+
title: "Number",
|
|
2621
|
+
value: "number",
|
|
2622
|
+
component: ListItemStyle
|
|
2623
|
+
}],
|
|
2624
|
+
marks: {
|
|
2625
|
+
decorators: [
|
|
2626
|
+
{
|
|
2627
|
+
title: "Bold",
|
|
2628
|
+
value: "strong"
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
title: "Italic",
|
|
2632
|
+
value: "em"
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
title: "Strikethrough",
|
|
2636
|
+
value: "strike-through"
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
title: "Code",
|
|
2640
|
+
value: "code",
|
|
2641
|
+
component: CodeDecorator
|
|
2642
|
+
}
|
|
2643
|
+
],
|
|
2644
|
+
annotations: [linkAnnotation]
|
|
2645
|
+
}
|
|
2646
|
+
}),
|
|
2647
|
+
defineArrayMember({
|
|
2648
|
+
name: imageTypeName,
|
|
2649
|
+
type: imageTypeName
|
|
2650
|
+
}),
|
|
2651
|
+
defineArrayMember({
|
|
2652
|
+
name: videoTypeName,
|
|
2653
|
+
type: videoTypeName
|
|
2654
|
+
}),
|
|
2655
|
+
defineArrayMember({
|
|
2656
|
+
name: codeTypeName,
|
|
2657
|
+
type: codeTypeName
|
|
2658
|
+
}),
|
|
2659
|
+
defineArrayMember({
|
|
2660
|
+
name: calloutTypeName,
|
|
2661
|
+
type: calloutTypeName
|
|
2662
|
+
}),
|
|
2663
|
+
defineArrayMember({
|
|
2664
|
+
name: horizontalRuleTypeName,
|
|
2665
|
+
type: horizontalRuleTypeName
|
|
2666
|
+
}),
|
|
2667
|
+
...customBlocks.map((block) => defineArrayMember({
|
|
2668
|
+
name: block.schema.name,
|
|
2669
|
+
type: block.schema.name
|
|
2670
|
+
}))
|
|
2671
|
+
]
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
/**
|
|
2675
|
+
* Creates the guide document type, with a content field offering the built-in blocks and any custom ones.
|
|
2676
|
+
*
|
|
2677
|
+
* @param customBlocks - Custom blocks added by the site.
|
|
2678
|
+
* @returns The guide document type.
|
|
2679
|
+
*/
|
|
2680
|
+
function createGuideType(customBlocks = []) {
|
|
2681
|
+
return defineType({
|
|
2682
|
+
name: guideTypeName,
|
|
2683
|
+
type: "document",
|
|
2684
|
+
title: "Handbook Guide",
|
|
2685
|
+
description: "Handbook page written in rich text.",
|
|
2686
|
+
icon: createSanityIcon(BookOpenTextIcon),
|
|
2687
|
+
preview: {
|
|
2688
|
+
select: {
|
|
2689
|
+
title: "title",
|
|
2690
|
+
description: "description"
|
|
2691
|
+
},
|
|
2692
|
+
prepare(selection) {
|
|
2693
|
+
let { title, description } = selection;
|
|
2694
|
+
return {
|
|
2695
|
+
title: title ?? "Untitled",
|
|
2696
|
+
subtitle: description
|
|
2697
|
+
};
|
|
2698
|
+
}
|
|
2699
|
+
},
|
|
2700
|
+
fields: [
|
|
2701
|
+
defineField({
|
|
2702
|
+
name: "title",
|
|
2703
|
+
type: "string",
|
|
2704
|
+
description: "Title shown in the Handbook sidebar and as the guide heading.",
|
|
2705
|
+
validation: (rule) => rule.required()
|
|
2706
|
+
}),
|
|
2707
|
+
defineField({
|
|
2708
|
+
name: "description",
|
|
2709
|
+
type: "string",
|
|
2710
|
+
description: "Short introduction shown below the heading."
|
|
2711
|
+
}),
|
|
2712
|
+
createGuideContentField(customBlocks)
|
|
2713
|
+
]
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
function ListPlusIcon(props) {
|
|
2717
|
+
let $ = c(7), t0, t1, t2, t3, t4;
|
|
2718
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M16 5H3" }), t1 = /* @__PURE__ */ jsx("path", { d: "M11 12H3" }), t2 = /* @__PURE__ */ jsx("path", { d: "M16 19H3" }), t3 = /* @__PURE__ */ jsx("path", { d: "M18 9v6" }), t4 = /* @__PURE__ */ jsx("path", { d: "M21 12h-6" }), $[0] = t0, $[1] = t1, $[2] = t2, $[3] = t3, $[4] = t4) : (t0 = $[0], t1 = $[1], t2 = $[2], t3 = $[3], t4 = $[4]);
|
|
2719
|
+
let t5;
|
|
2720
|
+
return $[5] === props ? t5 = $[6] : (t5 = /* @__PURE__ */ jsxs("svg", {
|
|
2721
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2722
|
+
width: 24,
|
|
2723
|
+
height: 24,
|
|
2724
|
+
viewBox: "0 0 24 24",
|
|
2725
|
+
fill: "none",
|
|
2726
|
+
stroke: "currentColor",
|
|
2727
|
+
strokeWidth: 2,
|
|
2728
|
+
strokeLinecap: "round",
|
|
2729
|
+
strokeLinejoin: "round",
|
|
2730
|
+
...props,
|
|
2731
|
+
children: [
|
|
2732
|
+
t0,
|
|
2733
|
+
t1,
|
|
2734
|
+
t2,
|
|
2735
|
+
t3,
|
|
2736
|
+
t4
|
|
2737
|
+
]
|
|
2738
|
+
}), $[5] = props, $[6] = t5), t5;
|
|
2739
|
+
}
|
|
2740
|
+
const handbookType = defineType({
|
|
2741
|
+
name: handbookTypeName,
|
|
2742
|
+
type: "document",
|
|
2743
|
+
title: "Handbook",
|
|
2744
|
+
description: "Groups of guides shown in the Handbook sidebar, in order.",
|
|
2745
|
+
icon: createSanityIcon(BookTextIcon),
|
|
2746
|
+
preview: { prepare() {
|
|
2747
|
+
return { title: "Handbook" };
|
|
2748
|
+
} },
|
|
2749
|
+
fields: [defineField({
|
|
2750
|
+
name: "groups",
|
|
2751
|
+
type: "array",
|
|
2752
|
+
description: "Groups of guides shown in the Handbook sidebar, in order. Each group has a title and a list of guides, also in order.",
|
|
2753
|
+
of: [defineArrayMember({
|
|
2754
|
+
name: "group",
|
|
2755
|
+
type: "object",
|
|
2756
|
+
description: "Sidebar section holding a list of guides.",
|
|
2757
|
+
icon: createSanityIcon(ListPlusIcon),
|
|
2758
|
+
fields: [defineField({
|
|
2759
|
+
name: "title",
|
|
2760
|
+
type: "string",
|
|
2761
|
+
description: "Heading shown above the group in the sidebar.",
|
|
2762
|
+
validation: (rule) => rule.required()
|
|
2763
|
+
}), defineField({
|
|
2764
|
+
name: "guides",
|
|
2765
|
+
type: "array",
|
|
2766
|
+
description: "Guides in the group, in order. Drag to reorder.",
|
|
2767
|
+
of: [defineArrayMember({
|
|
2768
|
+
name: "guide",
|
|
2769
|
+
type: "reference",
|
|
2770
|
+
to: [{ type: guideTypeName }]
|
|
2771
|
+
})]
|
|
2772
|
+
})],
|
|
2773
|
+
preview: {
|
|
2774
|
+
select: {
|
|
2775
|
+
title: "title",
|
|
2776
|
+
guide0: "guides.0.title",
|
|
2777
|
+
guide1: "guides.1.title",
|
|
2778
|
+
guide2: "guides.2.title"
|
|
2779
|
+
},
|
|
2780
|
+
prepare(selection) {
|
|
2781
|
+
let { title, guide0, guide1, guide2 } = selection, shown = [
|
|
2782
|
+
guide0,
|
|
2783
|
+
guide1,
|
|
2784
|
+
guide2
|
|
2785
|
+
].filter((guide) => isDefined(guide)).slice(0, 2), hasMore = isDefined(guide2);
|
|
2786
|
+
function formatSubtitle() {
|
|
2787
|
+
return isDefined(shown) ? hasMore ? `${shown.join(", ")}, and others` : shown.join(" and ") : "No guides selected";
|
|
2788
|
+
}
|
|
2789
|
+
return {
|
|
2790
|
+
title: title ?? "Group",
|
|
2791
|
+
subtitle: formatSubtitle()
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
})]
|
|
2796
|
+
})]
|
|
2797
|
+
}), handbookPlugin = definePlugin((config) => {
|
|
2753
2798
|
let { title, sidebarTitle, roles, blocks, editors, undocumentedFieldMessage } = config;
|
|
2754
2799
|
setConfiguredEditors(editors);
|
|
2755
2800
|
let resolved = {
|
|
2756
2801
|
sidebarTitle: sidebarTitle ?? "Handbook",
|
|
2757
2802
|
roles,
|
|
2758
2803
|
blocks: blocks ?? [],
|
|
2759
|
-
undocumentedFieldMessage: undocumentedFieldMessage ?? "This field
|
|
2804
|
+
undocumentedFieldMessage: undocumentedFieldMessage ?? "This field isn't documented yet. Ask your development team for guidance."
|
|
2760
2805
|
}, guideType = createGuideType(resolved.blocks);
|
|
2761
2806
|
return {
|
|
2762
|
-
name:
|
|
2807
|
+
name: pluginName,
|
|
2763
2808
|
schema: { types: [
|
|
2764
2809
|
handbookType,
|
|
2765
2810
|
guideType,
|
|
@@ -2792,25 +2837,26 @@ const handbookPlugin = definePlugin((config) => {
|
|
|
2792
2837
|
};
|
|
2793
2838
|
});
|
|
2794
2839
|
/**
|
|
2795
|
-
* Creates
|
|
2796
|
-
* not permitted to edit them.
|
|
2840
|
+
* Creates Structure tool items for the Handbook documents, or none when the current user can't edit them.
|
|
2797
2841
|
*
|
|
2798
|
-
* @param structureBuilder - The
|
|
2799
|
-
* @param context - The
|
|
2800
|
-
* @param editors - Email addresses
|
|
2801
|
-
* @returns
|
|
2842
|
+
* @param structureBuilder - The structure builder.
|
|
2843
|
+
* @param context - The structure context, with the current user.
|
|
2844
|
+
* @param editors - Email addresses of the editors, defaulting to the configured list.
|
|
2845
|
+
* @returns List items for the Handbook document and the guides list, oldest guide first.
|
|
2802
2846
|
* @public
|
|
2803
2847
|
*/
|
|
2804
2848
|
function handbookStructure(structureBuilder, context, editors) {
|
|
2805
2849
|
if (!isPermittedEditor(editors, context.currentUser?.email)) return [];
|
|
2806
2850
|
let { listItem, document, documentTypeList } = structureBuilder;
|
|
2807
|
-
return [listItem().title("Handbook").icon(createSanityIcon(BookTextIcon)).child(document().id(handbookTypeName).schemaType(handbookTypeName).title("Handbook")), listItem().title("Handbook Guides").icon(createSanityIcon(BookOpenTextIcon)).child(documentTypeList(guideTypeName).title("Handbook Guides")
|
|
2851
|
+
return [listItem().title("Handbook").icon(createSanityIcon(BookTextIcon)).child(document().id(handbookTypeName).schemaType(handbookTypeName).title("Handbook")), listItem().title("Handbook Guides").icon(createSanityIcon(BookOpenTextIcon)).child(documentTypeList(guideTypeName).title("Handbook Guides").defaultOrdering([{
|
|
2852
|
+
field: "_createdAt",
|
|
2853
|
+
direction: "asc"
|
|
2854
|
+
}]))];
|
|
2808
2855
|
}
|
|
2809
2856
|
/**
|
|
2810
|
-
* Checks whether the current user
|
|
2811
|
-
* unrestricted access.
|
|
2857
|
+
* Checks whether the current user can edit Handbook documents. Without an editors list, everyone can.
|
|
2812
2858
|
*
|
|
2813
|
-
* @param editors - Email addresses
|
|
2859
|
+
* @param editors - Email addresses of the editors, defaulting to the configured list.
|
|
2814
2860
|
* @returns Whether the current user can edit Handbook documents.
|
|
2815
2861
|
* @public
|
|
2816
2862
|
*/
|