@backmatter/studio 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{UiKitApp-CMMcsaX4.js → UiKitApp-CgGyJiC4.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-DW0sLdpJ.js → WorkspaceRoutes-CzCBnhNt.js} +18900 -18798
- package/dist/chunks/{dashboard-By0P4Yny.js → dashboard-w-mlsGky.js} +2 -2
- package/dist/chunks/{index-DTPUqaHE.js → index-_XfFuFSU.js} +1 -1
- package/dist/dashboard.js +2 -2
- package/dist/index.js +2 -2
- package/dist/studio.css +28 -0
- package/package.json +1 -1
- package/src/fields/LinkFieldInput.tsx +182 -33
- package/src/pages/MediaFieldInput.tsx +1 -1
- package/src/pages/MediaGalleryPage.tsx +36 -3
- package/src/ui/Input.tsx +134 -35
|
@@ -3,7 +3,7 @@ var st = (e, t, n) => t in e ? rt(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var $ = (e, t, n) => st(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsxs as w, jsx as i, Fragment as re } from "react/jsx-runtime";
|
|
5
5
|
import { useRef as qe, useCallback as it, useSyncExternalStore as at, useState as E, useEffect as W, lazy as ot, Suspense as lt } from "react";
|
|
6
|
-
import { X as Ie, V as R, k as ze, an as Be, ao as be, ap as ct, aq as ut, ar as Fe, as as Me, at as De, au as dt, av as ft, P as He, aw as ht, ax as ae, ah as K, Z as We, ay as xt, az as $e, ai as pt, ak as se, aa as Q, ab as Z, Y as oe, aA as gt, W as F, aB as mt, J as we, aC as ee, aj as yt, aD as vt, aE as bt, aF as wt, aG as kt, aH as St, f as Rt, aI as Et, a6 as _t, aJ as jt, aK as Tt, z as Pt, B as Ot, I as Lt, aL as Nt, aM as Ut, aN as At, K as Ct, aO as qt, R as It, L as zt, M as Bt, N as Ft, O as D, Q as Mt, U as Dt } from "./WorkspaceRoutes-
|
|
6
|
+
import { X as Ie, V as R, k as ze, an as Be, ao as be, ap as ct, aq as ut, ar as Fe, as as Me, at as De, au as dt, av as ft, P as He, aw as ht, ax as ae, ah as K, Z as We, ay as xt, az as $e, ai as pt, ak as se, aa as Q, ab as Z, Y as oe, aA as gt, W as F, aB as mt, J as we, aC as ee, aj as yt, aD as vt, aE as bt, aF as wt, aG as kt, aH as St, f as Rt, aI as Et, a6 as _t, aJ as jt, aK as Tt, z as Pt, B as Ot, I as Lt, aL as Nt, aM as Ut, aN as At, K as Ct, aO as qt, R as It, L as zt, M as Bt, N as Ft, O as D, Q as Mt, U as Dt } from "./WorkspaceRoutes-CzCBnhNt.js";
|
|
7
7
|
const te = /* @__PURE__ */ Object.create(null), G = (e) => {
|
|
8
8
|
var t, n;
|
|
9
9
|
return ((t = globalThis.process) == null ? void 0 : t.env) || ((n = globalThis.Deno) == null ? void 0 : n.env.toObject()) || globalThis.__env__ || (e ? te : globalThis);
|
|
@@ -1823,7 +1823,7 @@ function Or(e) {
|
|
|
1823
1823
|
const t = e.replace(/\/$/, "") || "/";
|
|
1824
1824
|
return t === "/__ui" || /^\/__ui\/[^/]+$/.test(t);
|
|
1825
1825
|
}
|
|
1826
|
-
const Lr = ot(() => import("./UiKitApp-
|
|
1826
|
+
const Lr = ot(() => import("./UiKitApp-CgGyJiC4.js").then((e) => ({
|
|
1827
1827
|
default: e.UiKitApp
|
|
1828
1828
|
})));
|
|
1829
1829
|
function Ir() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Rs = Object.defineProperty;
|
|
2
2
|
var Es = (r, e, t) => e in r ? Rs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var M = (r, e, t) => Es(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { aP as Bt, aQ as Bs, aR as a0, aS as ct, aT as xt, aU as ea, aV as Gn, aW as Is, aX as Ls, aY as Ds, aZ as La, a_ as Ps, a$ as Os, b0 as Le, b1 as qs } from "./WorkspaceRoutes-
|
|
4
|
+
import { aP as Bt, aQ as Bs, aR as a0, aS as ct, aT as xt, aU as ea, aV as Gn, aW as Is, aX as Ls, aY as Ds, aZ as La, a_ as Ps, a$ as Os, b0 as Le, b1 as qs } from "./WorkspaceRoutes-CzCBnhNt.js";
|
|
5
5
|
function Fs() {
|
|
6
6
|
return {
|
|
7
7
|
enter: {
|
package/dist/dashboard.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as a, i as s } from "./chunks/dashboard-
|
|
2
|
-
import { G as t, H as f } from "./chunks/WorkspaceRoutes-
|
|
1
|
+
import { A as a, i as s } from "./chunks/dashboard-w-mlsGky.js";
|
|
2
|
+
import { G as t, H as f } from "./chunks/WorkspaceRoutes-CzCBnhNt.js";
|
|
3
3
|
export {
|
|
4
4
|
a as DashboardApp,
|
|
5
5
|
t as configureStudio,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t, jsxs as u, Fragment as he } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect as pe, useEffect as p, useRef as ee, useState as m, useMemo as fe } from "react";
|
|
3
|
-
import { i as te, T as ge, E as be, C as ye, a as we, b as ve, u as ke, D as V, c as ne, d as H, e as qe, f as re, g as W, h as ze, p as Ee, j as Ce, k as w, l as v, m as Ne, n as Se, o as L, s as Le, r as Pe, q as Re, t as je, v as Ue, w as Te, x as Me, y as $e, z as Fe, B as Be, A as Oe, S as Ae, F as De, G as ie, H as U, I as Ge, J as _e, K as Ie, R as Ke, L as Ve, M as He, N as We, O as P, P as X, Q as Xe, U as Je, V as J, W as Qe } from "./chunks/WorkspaceRoutes-
|
|
4
|
-
import { X as kt } from "./chunks/WorkspaceRoutes-
|
|
3
|
+
import { i as te, T as ge, E as be, C as ye, a as we, b as ve, u as ke, D as V, c as ne, d as H, e as qe, f as re, g as W, h as ze, p as Ee, j as Ce, k as w, l as v, m as Ne, n as Se, o as L, s as Le, r as Pe, q as Re, t as je, v as Ue, w as Te, x as Me, y as $e, z as Fe, B as Be, A as Oe, S as Ae, F as De, G as ie, H as U, I as Ge, J as _e, K as Ie, R as Ke, L as Ve, M as He, N as We, O as P, P as X, Q as Xe, U as Je, V as J, W as Qe } from "./chunks/WorkspaceRoutes-CzCBnhNt.js";
|
|
4
|
+
import { X as kt } from "./chunks/WorkspaceRoutes-CzCBnhNt.js";
|
|
5
5
|
import { u as Ye, S as Ze } from "./chunks/define-studio-DlYjgrwr.js";
|
|
6
6
|
import { d as zt } from "./chunks/define-studio-DlYjgrwr.js";
|
|
7
7
|
const R = {
|
package/dist/studio.css
CHANGED
|
@@ -221,6 +221,10 @@
|
|
|
221
221
|
gap: 0;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
.x12mrbbr {
|
|
225
|
+
gap: 1px;
|
|
226
|
+
}
|
|
227
|
+
|
|
224
228
|
.x195vfkc {
|
|
225
229
|
gap: 2px;
|
|
226
230
|
}
|
|
@@ -471,6 +475,10 @@
|
|
|
471
475
|
padding-block: 0;
|
|
472
476
|
}
|
|
473
477
|
|
|
478
|
+
.xt0b8zv:hover {
|
|
479
|
+
text-decoration: underline;
|
|
480
|
+
}
|
|
481
|
+
|
|
474
482
|
.x1t8xw5s:focus {
|
|
475
483
|
border-color: color-mix(in srgb,var(--xw4dauw) 45%,var(--xz3qvk5));
|
|
476
484
|
}
|
|
@@ -1149,6 +1157,10 @@
|
|
|
1149
1157
|
flex-shrink: 2;
|
|
1150
1158
|
}
|
|
1151
1159
|
|
|
1160
|
+
.xo4cfa7 {
|
|
1161
|
+
flex-shrink: 3;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1152
1164
|
.x1a02dak {
|
|
1153
1165
|
flex-wrap: wrap;
|
|
1154
1166
|
}
|
|
@@ -2372,6 +2384,10 @@
|
|
|
2372
2384
|
left: 0;
|
|
2373
2385
|
}
|
|
2374
2386
|
|
|
2387
|
+
.xpnmzw7 {
|
|
2388
|
+
left: 12px;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2375
2391
|
.x54rlcq {
|
|
2376
2392
|
left: 2px;
|
|
2377
2393
|
}
|
|
@@ -2544,6 +2560,10 @@
|
|
|
2544
2560
|
max-height: min(var(--available-height),240px);
|
|
2545
2561
|
}
|
|
2546
2562
|
|
|
2563
|
+
.xo54sje {
|
|
2564
|
+
max-height: min(var(--available-height),24rem);
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2547
2567
|
.xsj38sl {
|
|
2548
2568
|
max-height: min(var(--available-height),420px);
|
|
2549
2569
|
}
|
|
@@ -2632,6 +2652,10 @@
|
|
|
2632
2652
|
max-width: calc(100vw - 32px);
|
|
2633
2653
|
}
|
|
2634
2654
|
|
|
2655
|
+
.x4bfss {
|
|
2656
|
+
max-width: min(max(var(--anchor-width),24rem),var(--available-width));
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2635
2659
|
.x2lwn1j {
|
|
2636
2660
|
min-height: 0;
|
|
2637
2661
|
}
|
|
@@ -3104,6 +3128,10 @@
|
|
|
3104
3128
|
width: 48px;
|
|
3105
3129
|
}
|
|
3106
3130
|
|
|
3131
|
+
.xekueh {
|
|
3132
|
+
width: 4rem;
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3107
3135
|
.x15yg21f {
|
|
3108
3136
|
width: 56px;
|
|
3109
3137
|
}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import * as stylex from "@stylexjs/stylex";
|
|
|
4
4
|
import {
|
|
5
5
|
documentLabel,
|
|
6
6
|
internalSuffixError,
|
|
7
|
+
isBareAnchor,
|
|
7
8
|
joinInternalLink,
|
|
8
9
|
linkSide,
|
|
9
10
|
matchesWhere,
|
|
@@ -12,7 +13,10 @@ import {
|
|
|
12
13
|
} from "@backmatter/core";
|
|
13
14
|
import type { SchemaField } from "../api";
|
|
14
15
|
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
15
|
-
import { Input, Select } from "../ui/Input";
|
|
16
|
+
import { Input, Select, type SelectOption } from "../ui/Input";
|
|
17
|
+
|
|
18
|
+
/** Select value for "This page": a bare `#anchor` on whichever page shows the link. */
|
|
19
|
+
const THIS_PAGE = "#";
|
|
16
20
|
|
|
17
21
|
type ModelRef = {
|
|
18
22
|
type: string;
|
|
@@ -60,15 +64,22 @@ function internalSuffixState(value: string): {
|
|
|
60
64
|
return { parts, showSuffix: true, selectValue: parts.path };
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
function modelGroupLabel(type: string): string {
|
|
68
|
+
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Routes grouped by model in schema order, each titled with its route beneath. */
|
|
63
72
|
function buildRouteOptions(
|
|
64
73
|
field: SchemaField,
|
|
65
74
|
models: ModelRef[],
|
|
66
75
|
documentLists: RelationDocumentLists | undefined,
|
|
67
|
-
):
|
|
76
|
+
): SelectOption[] {
|
|
68
77
|
if (!documentLists) return [];
|
|
69
|
-
const options:
|
|
78
|
+
const options: SelectOption[] = [];
|
|
70
79
|
for (const model of routableTypes(field, models)) {
|
|
80
|
+
const group = modelGroupLabel(model.type);
|
|
71
81
|
const docs = documentLists[model.type] ?? [];
|
|
82
|
+
const modelOptions: SelectOption[] = [];
|
|
72
83
|
for (const doc of docs) {
|
|
73
84
|
if (!matchesWhere({ slug: doc.slug, frontmatter: doc.frontmatter }, field.where)) {
|
|
74
85
|
continue;
|
|
@@ -76,13 +87,19 @@ function buildRouteOptions(
|
|
|
76
87
|
const route = routeFor(model, doc.slug);
|
|
77
88
|
if (route === "") continue;
|
|
78
89
|
const label = documentLabel(doc.frontmatter, model);
|
|
79
|
-
|
|
90
|
+
modelOptions.push({
|
|
80
91
|
value: route,
|
|
81
|
-
label: label
|
|
92
|
+
label: label || route,
|
|
93
|
+
description: label ? route : undefined,
|
|
94
|
+
group,
|
|
82
95
|
});
|
|
83
96
|
}
|
|
97
|
+
// Titles that open with a quote mark sort by their first letter.
|
|
98
|
+
modelOptions.sort((a, b) =>
|
|
99
|
+
a.label.localeCompare(b.label, undefined, { ignorePunctuation: true, sensitivity: "base" }),
|
|
100
|
+
);
|
|
101
|
+
options.push(...modelOptions);
|
|
84
102
|
}
|
|
85
|
-
options.sort((a, b) => a.label.localeCompare(b.label));
|
|
86
103
|
return options;
|
|
87
104
|
}
|
|
88
105
|
|
|
@@ -153,11 +170,15 @@ export function LinkFieldInput({
|
|
|
153
170
|
linkSide(raw) === "external" ? "external" : "internal",
|
|
154
171
|
);
|
|
155
172
|
const [pendingClearOf, setPendingClearOf] = useState<string | null>(null);
|
|
173
|
+
const [thisPagePicked, setThisPagePicked] = useState(false);
|
|
174
|
+
const [openParts, setOpenParts] = useState({ query: false, anchor: false });
|
|
156
175
|
const [lastSyncedRaw, setLastSyncedRaw] = useState(raw);
|
|
157
176
|
if (raw !== lastSyncedRaw) {
|
|
158
177
|
setLastSyncedRaw(raw);
|
|
159
178
|
if (raw !== lastEmittedRawRef.current) {
|
|
160
179
|
lastEmittedRawRef.current = null;
|
|
180
|
+
setThisPagePicked(false);
|
|
181
|
+
setOpenParts({ query: false, anchor: false });
|
|
161
182
|
if (raw !== "") {
|
|
162
183
|
setEditorSide(linkSide(raw) === "external" ? "external" : "internal");
|
|
163
184
|
}
|
|
@@ -217,22 +238,32 @@ export function LinkFieldInput({
|
|
|
217
238
|
);
|
|
218
239
|
}
|
|
219
240
|
|
|
220
|
-
const
|
|
241
|
+
const internal = raw === "" ? {
|
|
221
242
|
parts: { path: "", query: "", anchor: "" },
|
|
222
243
|
showSuffix: true,
|
|
223
244
|
selectValue: "",
|
|
224
245
|
} : internalSuffixState(raw);
|
|
225
|
-
|
|
226
|
-
//
|
|
246
|
+
const { parts, showSuffix } = internal;
|
|
247
|
+
// A bare anchor has no page to hold to a field's models or filter.
|
|
227
248
|
const bareAnchorAllowed = !(field.models && field.models.length > 0) && !field.where;
|
|
249
|
+
const bare = raw !== "" && isBareAnchor(raw);
|
|
250
|
+
const thisPage = bare || (raw === "" && thisPagePicked && bareAnchorAllowed);
|
|
228
251
|
const hasRoute = parts.path !== "";
|
|
229
|
-
const
|
|
230
|
-
const anchorEditable = showSuffix && (hasRoute || bareAnchorAllowed);
|
|
252
|
+
const selectValue = thisPage ? THIS_PAGE : internal.selectValue;
|
|
231
253
|
|
|
232
|
-
const options = buildRouteOptions(field, models, documentLists);
|
|
233
|
-
if (selectValue && !options.some((option) => option.value === selectValue)) {
|
|
254
|
+
const options: SelectOption[] = buildRouteOptions(field, models, documentLists);
|
|
255
|
+
if (selectValue && selectValue !== THIS_PAGE && !options.some((option) => option.value === selectValue)) {
|
|
234
256
|
options.unshift({ value: selectValue, label: selectValue });
|
|
235
257
|
}
|
|
258
|
+
if (bareAnchorAllowed || bare) {
|
|
259
|
+
options.unshift({ value: THIS_PAGE, label: "This page" });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const showAnchor =
|
|
263
|
+
showSuffix && (thisPage || (hasRoute && (openParts.anchor || parts.anchor !== "")));
|
|
264
|
+
const showQuery = showSuffix && hasRoute && (openParts.query || parts.query !== "");
|
|
265
|
+
const canAddAnchor = !readOnly && showSuffix && hasRoute && !showAnchor;
|
|
266
|
+
const canAddQuery = !readOnly && showSuffix && hasRoute && !showQuery;
|
|
236
267
|
|
|
237
268
|
const internalPressed = editorSide !== "external";
|
|
238
269
|
|
|
@@ -257,42 +288,121 @@ export function LinkFieldInput({
|
|
|
257
288
|
chip
|
|
258
289
|
searchable
|
|
259
290
|
clearable={!field.required}
|
|
260
|
-
placeholder="
|
|
291
|
+
placeholder="Choose a page"
|
|
261
292
|
options={options}
|
|
262
293
|
value={selectValue || null}
|
|
263
294
|
disabled={readOnly}
|
|
264
295
|
onValueChange={(next) => {
|
|
265
296
|
if (readOnly) return;
|
|
266
297
|
if (next == null) {
|
|
298
|
+
setThisPagePicked(false);
|
|
299
|
+
setOpenParts({ query: false, anchor: false });
|
|
267
300
|
emitChange(undefined);
|
|
268
301
|
return;
|
|
269
302
|
}
|
|
303
|
+
if (next === THIS_PAGE) {
|
|
304
|
+
setThisPagePicked(true);
|
|
305
|
+
const anchor = showSuffix ? parts.anchor : "";
|
|
306
|
+
if (anchor !== "") {
|
|
307
|
+
emitChange(`#${anchor}`);
|
|
308
|
+
} else if (raw !== "") {
|
|
309
|
+
emitChange(undefined);
|
|
310
|
+
}
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
setThisPagePicked(false);
|
|
270
314
|
emitChange(joinInternalLink(next, showSuffix ? parts.query : "", showSuffix ? parts.anchor : ""));
|
|
271
315
|
}}
|
|
272
316
|
/>
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
317
|
+
{showQuery ? (
|
|
318
|
+
<LinkPart
|
|
319
|
+
label="Query"
|
|
320
|
+
prefix="?"
|
|
321
|
+
placeholder="key=value"
|
|
322
|
+
value={parts.query}
|
|
323
|
+
readOnly={readOnly}
|
|
324
|
+
onChange={(query) => {
|
|
325
|
+
if (readOnly) return;
|
|
326
|
+
emitChange(joinInternalLink(parts.path, query, parts.anchor));
|
|
327
|
+
}}
|
|
328
|
+
/>
|
|
329
|
+
) : null}
|
|
330
|
+
{showAnchor ? (
|
|
331
|
+
<LinkPart
|
|
332
|
+
label="Anchor"
|
|
333
|
+
prefix="#"
|
|
334
|
+
placeholder="section-id"
|
|
335
|
+
value={parts.anchor}
|
|
336
|
+
readOnly={readOnly}
|
|
337
|
+
onChange={(anchor) => {
|
|
338
|
+
if (readOnly) return;
|
|
339
|
+
const next = thisPage
|
|
340
|
+
? joinInternalLink("", "", anchor)
|
|
341
|
+
: joinInternalLink(parts.path, parts.query, anchor);
|
|
342
|
+
emitChange(next === "" ? undefined : next);
|
|
343
|
+
}}
|
|
344
|
+
/>
|
|
345
|
+
) : null}
|
|
346
|
+
{canAddAnchor || canAddQuery ? (
|
|
347
|
+
<div {...stylex.props(styles.addRow)}>
|
|
348
|
+
{canAddAnchor ? (
|
|
349
|
+
<button
|
|
350
|
+
type="button"
|
|
351
|
+
{...stylex.props(styles.addButton)}
|
|
352
|
+
onClick={() => setOpenParts((open) => ({ ...open, anchor: true }))}
|
|
353
|
+
>
|
|
354
|
+
Add anchor
|
|
355
|
+
</button>
|
|
356
|
+
) : null}
|
|
357
|
+
{canAddQuery ? (
|
|
358
|
+
<button
|
|
359
|
+
type="button"
|
|
360
|
+
{...stylex.props(styles.addButton)}
|
|
361
|
+
onClick={() => setOpenParts((open) => ({ ...open, query: true }))}
|
|
362
|
+
>
|
|
363
|
+
Add query
|
|
364
|
+
</button>
|
|
365
|
+
) : null}
|
|
366
|
+
</div>
|
|
367
|
+
) : null}
|
|
292
368
|
</div>
|
|
293
369
|
);
|
|
294
370
|
}
|
|
295
371
|
|
|
372
|
+
function LinkPart({
|
|
373
|
+
label,
|
|
374
|
+
prefix,
|
|
375
|
+
placeholder,
|
|
376
|
+
value,
|
|
377
|
+
readOnly,
|
|
378
|
+
onChange,
|
|
379
|
+
}: {
|
|
380
|
+
label: "Query" | "Anchor";
|
|
381
|
+
prefix: string;
|
|
382
|
+
placeholder: string;
|
|
383
|
+
value: string;
|
|
384
|
+
readOnly?: boolean;
|
|
385
|
+
onChange: (value: string) => void;
|
|
386
|
+
}) {
|
|
387
|
+
return (
|
|
388
|
+
<label {...stylex.props(styles.partRow)}>
|
|
389
|
+
<span {...stylex.props(styles.partLabel)}>{label}</span>
|
|
390
|
+
<span {...stylex.props(styles.partInput)}>
|
|
391
|
+
<span aria-hidden {...stylex.props(styles.partPrefix)}>
|
|
392
|
+
{prefix}
|
|
393
|
+
</span>
|
|
394
|
+
<Input
|
|
395
|
+
aria-label={label}
|
|
396
|
+
placeholder={placeholder}
|
|
397
|
+
value={value}
|
|
398
|
+
readOnly={readOnly}
|
|
399
|
+
onChange={(event) => onChange(event.target.value)}
|
|
400
|
+
/>
|
|
401
|
+
</span>
|
|
402
|
+
</label>
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
|
|
296
406
|
const styles = stylex.create({
|
|
297
407
|
stack: {
|
|
298
408
|
display: "flex",
|
|
@@ -315,6 +425,45 @@ const styles = stylex.create({
|
|
|
315
425
|
fontSize: type.sm,
|
|
316
426
|
cursor: "pointer",
|
|
317
427
|
},
|
|
428
|
+
partRow: {
|
|
429
|
+
display: "flex",
|
|
430
|
+
alignItems: "center",
|
|
431
|
+
gap: space.sm,
|
|
432
|
+
},
|
|
433
|
+
partLabel: {
|
|
434
|
+
flexShrink: 0,
|
|
435
|
+
width: "4rem",
|
|
436
|
+
fontFamily: type.sans,
|
|
437
|
+
fontSize: type.xs,
|
|
438
|
+
color: colors.textMuted,
|
|
439
|
+
},
|
|
440
|
+
partInput: {
|
|
441
|
+
display: "flex",
|
|
442
|
+
alignItems: "center",
|
|
443
|
+
gap: space.xs,
|
|
444
|
+
flex: 1,
|
|
445
|
+
minWidth: 0,
|
|
446
|
+
},
|
|
447
|
+
partPrefix: {
|
|
448
|
+
flexShrink: 0,
|
|
449
|
+
fontFamily: type.sans,
|
|
450
|
+
fontSize: type.sm,
|
|
451
|
+
color: colors.textMuted,
|
|
452
|
+
},
|
|
453
|
+
addRow: {
|
|
454
|
+
display: "flex",
|
|
455
|
+
gap: space.md,
|
|
456
|
+
},
|
|
457
|
+
addButton: {
|
|
458
|
+
padding: 0,
|
|
459
|
+
borderWidth: 0,
|
|
460
|
+
backgroundColor: "transparent",
|
|
461
|
+
color: colors.textMuted,
|
|
462
|
+
fontFamily: type.sans,
|
|
463
|
+
fontSize: type.xs,
|
|
464
|
+
cursor: "pointer",
|
|
465
|
+
textDecoration: { default: "none", ":hover": "underline" },
|
|
466
|
+
},
|
|
318
467
|
sideButtonPressed: {
|
|
319
468
|
borderColor: colors.text,
|
|
320
469
|
fontWeight: 600,
|
|
@@ -69,6 +69,7 @@ export function MediaGalleryPage({
|
|
|
69
69
|
const dragDepth = useRef(0);
|
|
70
70
|
const scroller = useRef<HTMLDivElement>(null);
|
|
71
71
|
const grid = useRef<HTMLDivElement>(null);
|
|
72
|
+
const shownPicked = useRef(false);
|
|
72
73
|
const [columns, setColumns] = useState(1);
|
|
73
74
|
const loadingPage = useRef(false);
|
|
74
75
|
const request = useRef(0);
|
|
@@ -394,6 +395,15 @@ export function MediaGalleryPage({
|
|
|
394
395
|
const showEmpty =
|
|
395
396
|
settled && state.pending.length === 0 && state.loaded.length === 0 && state.total === 0;
|
|
396
397
|
|
|
398
|
+
// When the picker opens, bring the media already in use into view once.
|
|
399
|
+
useEffect(() => {
|
|
400
|
+
if (!pick || shownPicked.current || !pickedUrls?.length) return;
|
|
401
|
+
const tile = grid.current?.querySelector<HTMLElement>("button[aria-current='true']");
|
|
402
|
+
if (!tile) return;
|
|
403
|
+
shownPicked.current = true;
|
|
404
|
+
tile.scrollIntoView?.({ block: "nearest" });
|
|
405
|
+
});
|
|
406
|
+
|
|
397
407
|
return (
|
|
398
408
|
<div {...stylex.props(styles.page)}>
|
|
399
409
|
<div {...stylex.props(styles.toolbar)}>
|
|
@@ -485,8 +495,8 @@ export function MediaGalleryPage({
|
|
|
485
495
|
item={cell.item}
|
|
486
496
|
menu={!pick}
|
|
487
497
|
selected={
|
|
488
|
-
|
|
489
|
-
?
|
|
498
|
+
pickedUrls
|
|
499
|
+
? pickedUrls.includes(cell.item.url)
|
|
490
500
|
: !pick && !sharedId && cell.item.id === selectedId
|
|
491
501
|
}
|
|
492
502
|
canDelete={canDelete}
|
|
@@ -584,7 +594,17 @@ function MediaHit({
|
|
|
584
594
|
</button>
|
|
585
595
|
);
|
|
586
596
|
if (!menu) {
|
|
587
|
-
if (!selected
|
|
597
|
+
if (!selected) return image;
|
|
598
|
+
if (!onUnpick) {
|
|
599
|
+
return (
|
|
600
|
+
<>
|
|
601
|
+
{image}
|
|
602
|
+
<span data-media-in-use {...stylex.props(styles.inUse)}>
|
|
603
|
+
In use
|
|
604
|
+
</span>
|
|
605
|
+
</>
|
|
606
|
+
);
|
|
607
|
+
}
|
|
588
608
|
return (
|
|
589
609
|
<>
|
|
590
610
|
{image}
|
|
@@ -780,6 +800,19 @@ const styles = stylex.create({
|
|
|
780
800
|
picked: {
|
|
781
801
|
cursor: "default",
|
|
782
802
|
},
|
|
803
|
+
inUse: {
|
|
804
|
+
position: "absolute",
|
|
805
|
+
top: "12px",
|
|
806
|
+
left: "12px",
|
|
807
|
+
paddingInline: space.sm,
|
|
808
|
+
paddingBlock: "2px",
|
|
809
|
+
borderRadius: "999px",
|
|
810
|
+
backgroundColor: "rgba(24, 24, 27, 0.85)",
|
|
811
|
+
color: "#fafafa",
|
|
812
|
+
fontSize: type.xs,
|
|
813
|
+
fontWeight: 500,
|
|
814
|
+
pointerEvents: "none",
|
|
815
|
+
},
|
|
783
816
|
unpick: {
|
|
784
817
|
position: "absolute",
|
|
785
818
|
top: "12px",
|