@backmatter/studio 0.0.17 → 0.0.19

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.
Files changed (48) hide show
  1. package/dist/chunks/{UiKitApp-D7vllRQE.js → UiKitApp-B1ANqCac.js} +528 -481
  2. package/dist/chunks/{WorkspaceRoutes-DH1LD-2Q.js → WorkspaceRoutes-BHNGrf-j.js} +24955 -24119
  3. package/dist/chunks/{dashboard-Dsaeud2x.js → dashboard-b-W6dGm5.js} +586 -565
  4. package/dist/chunks/{index-CGMqw2NH.js → index-HYioDjux.js} +104 -104
  5. package/dist/dashboard.js +2 -2
  6. package/dist/index.js +166 -159
  7. package/dist/site-widget.css +25 -6
  8. package/dist/site-widget.js +6925 -6840
  9. package/dist/studio.css +171 -42
  10. package/package.json +2 -2
  11. package/src/api.ts +44 -1
  12. package/src/chat/ChatMessage.tsx +4 -4
  13. package/src/chat/ChatProvider.tsx +6 -0
  14. package/src/chat/chat-helpers.ts +54 -2
  15. package/src/chrome/CommandPalette.tsx +3 -3
  16. package/src/chrome/ContentExplorerSidebar.tsx +421 -74
  17. package/src/chrome/WorkspaceStatusBar.tsx +24 -24
  18. package/src/chrome/commit-error.ts +48 -60
  19. package/src/chrome/commit-failure.tsx +2 -2
  20. package/src/chrome/content-path-tree.ts +4 -0
  21. package/src/chrome/explorer-row-menu.ts +28 -0
  22. package/src/chrome/folder-create-context.ts +14 -0
  23. package/src/chrome/use-publish-check.ts +75 -0
  24. package/src/{pages/code-session-routes.ts → content-routes.ts} +6 -6
  25. package/src/fields/FieldControl.tsx +198 -64
  26. package/src/fields/LinkFieldInput.tsx +315 -0
  27. package/src/fields/choose-field-input.ts +5 -0
  28. package/src/fields/link-targets.ts +60 -0
  29. package/src/host-path.ts +13 -0
  30. package/src/pages/CodeSessionPage.tsx +6 -241
  31. package/src/pages/DocEditorPage.tsx +121 -178
  32. package/src/pages/EmbedPublishPage.tsx +13 -5
  33. package/src/pages/GithubConnectPage.tsx +1 -1
  34. package/src/pages/LoginPage.tsx +67 -5
  35. package/src/pages/MediaFieldInput.tsx +712 -37
  36. package/src/pages/MediaGalleryPage.tsx +69 -5
  37. package/src/pages/PreviewAddress.tsx +293 -0
  38. package/src/pages/WorkspaceHomePage.tsx +1 -1
  39. package/src/pages/code-session-boot.ts +0 -12
  40. package/src/pages/media-selection.ts +79 -0
  41. package/src/pages/ui-kit/colors.tsx +2 -0
  42. package/src/pages/ui-kit/fields.tsx +60 -0
  43. package/src/styles/themes.ts +2 -0
  44. package/src/styles/tokens.stylex.ts +1 -0
  45. package/src/ui/Button.tsx +14 -0
  46. package/src/ui/Field.tsx +12 -1
  47. package/src/ui/Input.tsx +191 -97
  48. package/src/ui/popup.ts +13 -6
@@ -4,10 +4,11 @@ import * as stylex from "@stylexjs/stylex";
4
4
  import { documentLabel, matchesWhere } from "@backmatter/core";
5
5
  import type { SchemaField } from "../api";
6
6
  import { resolveFieldInput, useStudioDefinition } from "../define-studio";
7
- import { colors, radius, space, type } from "../styles/tokens.stylex";
7
+ import { colors, space } from "../styles/tokens.stylex";
8
8
  import { Input, Select, Textarea } from "../ui/Input";
9
9
  import { MediaFieldInput } from "../pages/MediaFieldInput";
10
10
  import { chooseFieldInput } from "./choose-field-input";
11
+ import { LinkFieldInput } from "./LinkFieldInput";
11
12
  import { nestedStartsCollapsed, resolveObjectFields } from "./resolve-object-fields";
12
13
 
13
14
  function clamp(n: number, min: number, max: number): number {
@@ -88,7 +89,13 @@ export function JsonField({
88
89
  );
89
90
  }
90
91
 
91
- type ModelRef = { type: string; external?: boolean; fields?: Record<string, SchemaField> };
92
+ type ModelRef = {
93
+ type: string;
94
+ external?: boolean;
95
+ route?: string | false;
96
+ indexSlug?: string;
97
+ fields?: Record<string, SchemaField>;
98
+ };
92
99
  type RelationDocument = { slug: string; frontmatter: Record<string, unknown> };
93
100
  type RelationDocumentLists = Record<string, RelationDocument[]>;
94
101
 
@@ -408,6 +415,110 @@ function commitNumber(raw: string, onChange: (value: unknown) => void): void {
408
415
  onChange(parsed);
409
416
  }
410
417
 
418
+ function sliderPercent(value: number, min: number, max: number): number {
419
+ const span = max - min;
420
+ if (span === 0) return 0;
421
+ return ((value - min) / span) * 100;
422
+ }
423
+
424
+ function withStyle(
425
+ props: ReturnType<typeof stylex.props>,
426
+ extra: { width?: string; left?: string },
427
+ ): ReturnType<typeof stylex.props> {
428
+ return { ...props, style: { ...props.style, ...extra } };
429
+ }
430
+
431
+ function SliderField({
432
+ name,
433
+ min,
434
+ max,
435
+ step,
436
+ value,
437
+ readOnly,
438
+ onChange,
439
+ }: {
440
+ name: string;
441
+ min: number;
442
+ max: number;
443
+ step: number | "any";
444
+ value: unknown;
445
+ readOnly?: boolean;
446
+ onChange: (value: unknown) => void;
447
+ }) {
448
+ const numeric = typeof value === "number" ? value : value === "" ? NaN : Number(value);
449
+ const rangeValue = Number.isFinite(numeric) ? clamp(numeric, min, max) : min;
450
+ const storedText = value == null || value === "" ? "" : String(value);
451
+ const [draft, setDraft] = useState<string | null>(null);
452
+ const textValue = draft ?? storedText;
453
+ const percent = sliderPercent(rangeValue, min, max);
454
+ const thumbLeft = `calc(7px + (100% - 14px) * ${percent / 100})`;
455
+ const [keyFocus, setKeyFocus] = useState(false);
456
+ const [hot, setHot] = useState(false);
457
+ const fill = stylex.props(styles.sliderFill);
458
+ const thumb = stylex.props(
459
+ styles.sliderThumb,
460
+ hot && !readOnly && styles.sliderThumbHot,
461
+ keyFocus && styles.sliderThumbFocus,
462
+ );
463
+
464
+ return (
465
+ <div {...stylex.props(styles.sliderRow)}>
466
+ <div
467
+ {...stylex.props(styles.sliderTrack, readOnly && styles.sliderTrackDisabled)}
468
+ onPointerEnter={(event) => {
469
+ if (event.pointerType === "mouse") setHot(true);
470
+ }}
471
+ onPointerLeave={() => setHot(false)}
472
+ >
473
+ <div {...stylex.props(styles.sliderRail)} aria-hidden>
474
+ <div {...withStyle(fill, { width: `${percent}%` })} />
475
+ </div>
476
+ <div aria-hidden {...withStyle(thumb, { left: thumbLeft })} />
477
+ <input
478
+ type="range"
479
+ min={min}
480
+ max={max}
481
+ step={step}
482
+ value={String(rangeValue)}
483
+ disabled={readOnly}
484
+ aria-valuemin={min}
485
+ aria-valuemax={max}
486
+ aria-valuenow={rangeValue}
487
+ aria-valuetext={textValue === "" ? "empty" : textValue}
488
+ {...stylex.props(styles.sliderRange)}
489
+ onFocus={(event) => {
490
+ setKeyFocus(event.currentTarget.matches(":focus-visible"));
491
+ }}
492
+ onBlur={() => setKeyFocus(false)}
493
+ onChange={(event) => {
494
+ if (readOnly) return;
495
+ setDraft(null);
496
+ onChange(Number(event.target.value));
497
+ }}
498
+ />
499
+ </div>
500
+ <div {...stylex.props(styles.sliderValue)}>
501
+ <Input
502
+ value={textValue}
503
+ inputMode="decimal"
504
+ readOnly={readOnly}
505
+ disabled={readOnly}
506
+ spellCheck={false}
507
+ autoComplete="off"
508
+ aria-label={`${name} value`}
509
+ onBlur={() => setDraft(null)}
510
+ onChange={(event) => {
511
+ if (readOnly) return;
512
+ const raw = event.target.value;
513
+ setDraft(raw);
514
+ commitNumber(raw, onChange);
515
+ }}
516
+ />
517
+ </div>
518
+ </div>
519
+ );
520
+ }
521
+
411
522
  export function FieldControl({
412
523
  name,
413
524
  field,
@@ -474,44 +585,16 @@ export function FieldControl({
474
585
  }
475
586
 
476
587
  if (kind === "slider" && typeof field.min === "number" && typeof field.max === "number") {
477
- const min = field.min;
478
- const max = field.max;
479
- const step = typeof field.step === "number" ? field.step : "any";
480
- const numeric = typeof value === "number" ? value : value === "" ? NaN : Number(value);
481
- const rangeValue = Number.isFinite(numeric) ? clamp(numeric, min, max) : min;
482
- const textValue = value == null || value === "" ? "" : String(value);
483
588
  return (
484
- <div {...stylex.props(styles.sliderRow)}>
485
- <input
486
- type="range"
487
- min={min}
488
- max={max}
489
- step={step}
490
- value={String(rangeValue)}
491
- disabled={readOnly}
492
- aria-valuemin={min}
493
- aria-valuemax={max}
494
- aria-valuenow={rangeValue}
495
- {...stylex.props(styles.range)}
496
- onChange={(event) => {
497
- if (readOnly) return;
498
- onChange(Number(event.target.value));
499
- }}
500
- />
501
- <input
502
- type="text"
503
- inputMode="decimal"
504
- value={textValue}
505
- readOnly={readOnly}
506
- disabled={readOnly}
507
- aria-label={`${name} value`}
508
- {...stylex.props(styles.sliderText)}
509
- onChange={(event) => {
510
- if (readOnly) return;
511
- commitNumber(event.target.value, onChange);
512
- }}
513
- />
514
- </div>
589
+ <SliderField
590
+ name={name}
591
+ min={field.min}
592
+ max={field.max}
593
+ step={typeof field.step === "number" ? field.step : "any"}
594
+ value={value}
595
+ readOnly={readOnly}
596
+ onChange={onChange}
597
+ />
515
598
  );
516
599
  }
517
600
 
@@ -542,7 +625,9 @@ export function FieldControl({
542
625
  }
543
626
 
544
627
  if (kind === "media") {
545
- return <MediaFieldInput name={name} value={value} readOnly={readOnly} onChange={onChange} />;
628
+ return (
629
+ <MediaFieldInput name={name} field={field} value={value} readOnly={readOnly} onChange={onChange} />
630
+ );
546
631
  }
547
632
 
548
633
  if (kind === "relation") {
@@ -559,6 +644,20 @@ export function FieldControl({
559
644
  );
560
645
  }
561
646
 
647
+ if (kind === "link") {
648
+ return (
649
+ <LinkFieldInput
650
+ name={name}
651
+ field={field}
652
+ value={value}
653
+ models={models}
654
+ documentLists={documentLists}
655
+ readOnly={readOnly}
656
+ onChange={onChange}
657
+ />
658
+ );
659
+ }
660
+
562
661
  if (kind === "boolean") {
563
662
  return (
564
663
  <input
@@ -661,39 +760,74 @@ const styles = stylex.create({
661
760
  sliderRow: {
662
761
  display: "flex",
663
762
  alignItems: "center",
664
- gap: space.md,
763
+ gap: space.lg,
665
764
  },
666
- range: {
765
+ sliderTrack: {
766
+ position: "relative",
667
767
  flex: 1,
668
768
  minWidth: 0,
669
- height: "16px",
769
+ height: "32px",
770
+ display: "flex",
771
+ alignItems: "center",
772
+ touchAction: "manipulation",
773
+ },
774
+ sliderTrackDisabled: {
775
+ opacity: 0.55,
776
+ },
777
+ sliderRail: {
778
+ position: "absolute",
779
+ left: "7px",
780
+ right: "7px",
781
+ height: "2px",
782
+ borderRadius: "999px",
783
+ backgroundColor: colors.border,
784
+ pointerEvents: "none",
785
+ },
786
+ sliderFill: {
787
+ height: "100%",
788
+ borderRadius: "999px",
789
+ backgroundColor: colors.text,
790
+ },
791
+ sliderThumb: {
792
+ position: "absolute",
793
+ top: "50%",
794
+ boxSizing: "border-box",
795
+ width: "14px",
796
+ height: "14px",
797
+ borderRadius: "999px",
798
+ borderWidth: "1.5px",
799
+ borderStyle: "solid",
800
+ borderColor: colors.text,
801
+ backgroundColor: colors.bgSurface,
802
+ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.16)",
803
+ transform: "translate(-50%, -50%)",
804
+ pointerEvents: "none",
805
+ },
806
+ sliderThumbHot: {
807
+ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
808
+ },
809
+ sliderThumbFocus: {
810
+ boxShadow: `0 0 0 2px ${colors.bgSurface}, 0 0 0 4px ${colors.focus}`,
811
+ },
812
+ sliderRange: {
813
+ position: "absolute",
814
+ left: "7px",
815
+ top: 0,
816
+ width: "calc(100% - 14px)",
817
+ height: "100%",
670
818
  margin: 0,
671
- accentColor: colors.text,
819
+ opacity: 0,
672
820
  cursor: "pointer",
821
+ appearance: "none",
822
+ touchAction: "manipulation",
823
+ ":disabled": {
824
+ cursor: "default",
825
+ },
673
826
  },
674
- sliderText: {
675
- boxSizing: "border-box",
827
+ sliderValue: {
676
828
  width: "4.5rem",
677
829
  flexShrink: 0,
678
- minHeight: "32px",
679
- paddingInline: space.md,
680
- paddingBlock: space.sm,
681
- borderRadius: radius.md,
682
- borderWidth: 1,
683
- borderStyle: "solid",
684
- borderColor: colors.border,
685
- backgroundColor: colors.bgInput,
686
- color: colors.text,
687
- fontSize: type.md,
688
830
  fontVariantNumeric: "tabular-nums",
689
- outline: "none",
690
- ":focus": {
691
- borderColor: colors.focus,
692
- outlineWidth: 2,
693
- outlineStyle: "solid",
694
- outlineColor: colors.focus,
695
- outlineOffset: -1,
696
- },
697
831
  },
698
832
  colorRow: {
699
833
  display: "flex",
@@ -0,0 +1,315 @@
1
+ // packages/studio/src/fields/LinkFieldInput.tsx
2
+ import { useRef, useState } from "react";
3
+ import * as stylex from "@stylexjs/stylex";
4
+ import {
5
+ documentLabel,
6
+ internalSuffixError,
7
+ joinInternalLink,
8
+ linkSide,
9
+ matchesWhere,
10
+ routeFor,
11
+ splitInternalLink,
12
+ } from "@backmatter/core";
13
+ import type { SchemaField } from "../api";
14
+ import { colors, radius, space, type } from "../styles/tokens.stylex";
15
+ import { Input, Select } from "../ui/Input";
16
+
17
+ type ModelRef = {
18
+ type: string;
19
+ external?: boolean;
20
+ route?: string | false;
21
+ indexSlug?: string;
22
+ fields?: Record<string, SchemaField>;
23
+ };
24
+ type RelationDocument = { slug: string; frontmatter: Record<string, unknown> };
25
+ type RelationDocumentLists = Record<string, RelationDocument[]>;
26
+
27
+ function routableTypes(field: SchemaField, models: ModelRef[]): ModelRef[] {
28
+ if (field.models && field.models.length > 0) {
29
+ return field.models
30
+ .map((type) => models.find((model) => model.type === type))
31
+ .filter((model): model is ModelRef => Boolean(model && !model.external && model.route !== false));
32
+ }
33
+ return models.filter((model) => !model.external && model.route !== false);
34
+ }
35
+
36
+ function suffixPresent(value: string): { query: boolean; anchor: boolean } {
37
+ const hashIndex = value.indexOf("#");
38
+ const preHash = hashIndex === -1 ? value : value.slice(0, hashIndex);
39
+ return { query: preHash.includes("?"), anchor: hashIndex !== -1 };
40
+ }
41
+
42
+ function internalSuffixState(value: string): {
43
+ parts: ReturnType<typeof splitInternalLink>;
44
+ showSuffix: boolean;
45
+ selectValue: string;
46
+ } {
47
+ const parts = splitInternalLink(value);
48
+ const side = linkSide(value);
49
+ if (side !== "internal") {
50
+ return { parts, showSuffix: false, selectValue: value };
51
+ }
52
+ const present = suffixPresent(value);
53
+ const suffixErr = internalSuffixError(
54
+ { query: parts.query, anchor: parts.anchor },
55
+ present,
56
+ );
57
+ if (suffixErr !== null) {
58
+ return { parts, showSuffix: false, selectValue: value };
59
+ }
60
+ return { parts, showSuffix: true, selectValue: parts.path };
61
+ }
62
+
63
+ function buildRouteOptions(
64
+ field: SchemaField,
65
+ models: ModelRef[],
66
+ documentLists: RelationDocumentLists | undefined,
67
+ ): Array<{ value: string; label: string }> {
68
+ if (!documentLists) return [];
69
+ const options: Array<{ value: string; label: string }> = [];
70
+ for (const model of routableTypes(field, models)) {
71
+ const docs = documentLists[model.type] ?? [];
72
+ for (const doc of docs) {
73
+ if (!matchesWhere({ slug: doc.slug, frontmatter: doc.frontmatter }, field.where)) {
74
+ continue;
75
+ }
76
+ const route = routeFor(model, doc.slug);
77
+ if (route === "") continue;
78
+ const label = documentLabel(doc.frontmatter, model);
79
+ options.push({
80
+ value: route,
81
+ label: label ? `${label} ${route}` : route,
82
+ });
83
+ }
84
+ }
85
+ options.sort((a, b) => a.label.localeCompare(b.label));
86
+ return options;
87
+ }
88
+
89
+ function SideToggle({
90
+ internalPressed,
91
+ readOnly,
92
+ onPick,
93
+ }: {
94
+ internalPressed: boolean;
95
+ readOnly?: boolean;
96
+ onPick: (side: "internal" | "external") => void;
97
+ }) {
98
+ return (
99
+ <div {...stylex.props(styles.sideRow)}>
100
+ <button
101
+ type="button"
102
+ aria-pressed={internalPressed}
103
+ disabled={readOnly}
104
+ {...stylex.props(styles.sideButton, internalPressed && styles.sideButtonPressed)}
105
+ onClick={() => {
106
+ if (readOnly || internalPressed) return;
107
+ onPick("internal");
108
+ }}
109
+ >
110
+ Internal
111
+ </button>
112
+ <button
113
+ type="button"
114
+ aria-pressed={!internalPressed}
115
+ disabled={readOnly}
116
+ {...stylex.props(styles.sideButton, !internalPressed && styles.sideButtonPressed)}
117
+ onClick={() => {
118
+ if (readOnly || !internalPressed) return;
119
+ onPick("external");
120
+ }}
121
+ >
122
+ External
123
+ </button>
124
+ </div>
125
+ );
126
+ }
127
+
128
+ export function LinkFieldInput({
129
+ name,
130
+ field,
131
+ value,
132
+ models,
133
+ documentLists,
134
+ readOnly,
135
+ onChange,
136
+ }: {
137
+ name: string;
138
+ field: SchemaField;
139
+ value: unknown;
140
+ models: ModelRef[];
141
+ documentLists?: RelationDocumentLists;
142
+ readOnly?: boolean;
143
+ onChange: (value: unknown) => void;
144
+ }) {
145
+ const raw = value == null || value === "" ? "" : String(value);
146
+ const sideToggle = field.to === undefined;
147
+ const lastEmittedRawRef = useRef<string | null>(null);
148
+ const emitChange = (next: unknown) => {
149
+ lastEmittedRawRef.current = next == null || next === "" ? "" : String(next);
150
+ onChange(next);
151
+ };
152
+ const [editorSide, setEditorSide] = useState<"internal" | "external">(() =>
153
+ linkSide(raw) === "external" ? "external" : "internal",
154
+ );
155
+ const [pendingClearOf, setPendingClearOf] = useState<string | null>(null);
156
+ const [lastSyncedRaw, setLastSyncedRaw] = useState(raw);
157
+ if (raw !== lastSyncedRaw) {
158
+ setLastSyncedRaw(raw);
159
+ if (raw !== lastEmittedRawRef.current) {
160
+ lastEmittedRawRef.current = null;
161
+ if (raw !== "") {
162
+ setEditorSide(linkSide(raw) === "external" ? "external" : "internal");
163
+ }
164
+ }
165
+ if (pendingClearOf !== null && raw !== pendingClearOf) {
166
+ setPendingClearOf(null);
167
+ }
168
+ }
169
+
170
+ if (field.to === "external") {
171
+ return (
172
+ <Input
173
+ value={raw}
174
+ readOnly={readOnly}
175
+ onChange={(event) => {
176
+ if (readOnly) return;
177
+ const next = event.target.value;
178
+ emitChange(next === "" ? undefined : next);
179
+ }}
180
+ />
181
+ );
182
+ }
183
+
184
+ const forceInternal = field.to === "internal";
185
+ const internalUi = forceInternal || editorSide !== "external";
186
+ const staleInternalOnExternalSide =
187
+ editorSide === "external" && raw !== "" && raw === pendingClearOf;
188
+ const externalInputValue = staleInternalOnExternalSide ? "" : raw;
189
+
190
+ if (!internalUi) {
191
+ return (
192
+ <div {...stylex.props(styles.stack)}>
193
+ {sideToggle ? (
194
+ <SideToggle
195
+ internalPressed={false}
196
+ readOnly={readOnly}
197
+ onPick={(picked) => {
198
+ if (readOnly) return;
199
+ setEditorSide(picked);
200
+ if (raw !== "") {
201
+ setPendingClearOf(raw);
202
+ emitChange(undefined);
203
+ }
204
+ }}
205
+ />
206
+ ) : null}
207
+ <Input
208
+ value={externalInputValue}
209
+ readOnly={readOnly}
210
+ onChange={(event) => {
211
+ if (readOnly) return;
212
+ const next = event.target.value;
213
+ emitChange(next === "" ? undefined : next);
214
+ }}
215
+ />
216
+ </div>
217
+ );
218
+ }
219
+
220
+ const { parts, showSuffix, selectValue } = raw === "" ? {
221
+ parts: { path: "", query: "", anchor: "" },
222
+ showSuffix: false,
223
+ selectValue: "",
224
+ } : internalSuffixState(raw);
225
+
226
+ const options = buildRouteOptions(field, models, documentLists);
227
+ if (selectValue && !options.some((option) => option.value === selectValue)) {
228
+ options.unshift({ value: selectValue, label: selectValue });
229
+ }
230
+
231
+ const internalPressed = editorSide !== "external";
232
+
233
+ return (
234
+ <div {...stylex.props(styles.stack)}>
235
+ {sideToggle ? (
236
+ <SideToggle
237
+ internalPressed={internalPressed}
238
+ readOnly={readOnly}
239
+ onPick={(picked) => {
240
+ if (readOnly) return;
241
+ setEditorSide(picked);
242
+ if (raw !== "") {
243
+ setPendingClearOf(raw);
244
+ emitChange(undefined);
245
+ }
246
+ }}
247
+ />
248
+ ) : null}
249
+ <Select
250
+ name={name}
251
+ chip
252
+ searchable
253
+ clearable={!field.required}
254
+ placeholder="Select a value"
255
+ options={options}
256
+ value={selectValue || null}
257
+ disabled={readOnly}
258
+ onValueChange={(next) => {
259
+ if (readOnly) return;
260
+ if (next == null) {
261
+ emitChange(undefined);
262
+ return;
263
+ }
264
+ emitChange(joinInternalLink(next, showSuffix ? parts.query : "", showSuffix ? parts.anchor : ""));
265
+ }}
266
+ />
267
+ <Input
268
+ aria-label="Query"
269
+ value={showSuffix ? parts.query : ""}
270
+ readOnly={readOnly || !showSuffix}
271
+ onChange={(event) => {
272
+ if (readOnly || !showSuffix) return;
273
+ emitChange(joinInternalLink(parts.path, event.target.value, parts.anchor));
274
+ }}
275
+ />
276
+ <Input
277
+ aria-label="Anchor"
278
+ value={showSuffix ? parts.anchor : ""}
279
+ readOnly={readOnly || !showSuffix}
280
+ onChange={(event) => {
281
+ if (readOnly || !showSuffix) return;
282
+ emitChange(joinInternalLink(parts.path, parts.query, event.target.value));
283
+ }}
284
+ />
285
+ </div>
286
+ );
287
+ }
288
+
289
+ const styles = stylex.create({
290
+ stack: {
291
+ display: "flex",
292
+ flexDirection: "column",
293
+ gap: space.sm,
294
+ },
295
+ sideRow: {
296
+ display: "flex",
297
+ gap: space.xs,
298
+ },
299
+ sideButton: {
300
+ paddingInline: space.md,
301
+ paddingBlock: space.xs,
302
+ borderRadius: radius.md,
303
+ borderWidth: 1,
304
+ borderStyle: "solid",
305
+ borderColor: colors.border,
306
+ backgroundColor: colors.bgInput,
307
+ color: colors.text,
308
+ fontSize: type.sm,
309
+ cursor: "pointer",
310
+ },
311
+ sideButtonPressed: {
312
+ borderColor: colors.text,
313
+ fontWeight: 600,
314
+ },
315
+ });
@@ -14,6 +14,7 @@ export type FieldInputKind =
14
14
  | "boolean"
15
15
  | "number"
16
16
  | "blocks"
17
+ | "link"
17
18
  | "text";
18
19
 
19
20
  export function chooseFieldInput(
@@ -48,6 +49,10 @@ export function chooseFieldInput(
48
49
  return "text";
49
50
  }
50
51
 
52
+ if (field.kind === "link") {
53
+ return "link";
54
+ }
55
+
51
56
  if (field.kind === "object") {
52
57
  return "object";
53
58
  }