@backmatter/studio 0.0.20 → 0.0.21
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-C269OA8v.js → UiKitApp-CMMcsaX4.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-B4B5jjje.js → WorkspaceRoutes-DW0sLdpJ.js} +27141 -26241
- package/dist/chunks/dashboard-By0P4Yny.js +1879 -0
- package/dist/chunks/{index-7-TtXaMq.js → index-DTPUqaHE.js} +1 -1
- package/dist/dashboard.js +2 -2
- package/dist/index.js +205 -194
- package/dist/site-widget.css +208 -0
- package/dist/site-widget.js +10495 -9947
- package/dist/studio.css +276 -32
- package/package.json +2 -2
- package/src/App.tsx +7 -1
- package/src/api.ts +106 -13
- package/src/chat/ChatFiles.tsx +261 -0
- package/src/chat/ChatMessage.tsx +5 -0
- package/src/chat/ChatPanel.tsx +218 -14
- package/src/chat/ChatProvider.tsx +72 -22
- package/src/chat/Composer.tsx +83 -6
- package/src/chat/PendingFileRow.tsx +188 -0
- package/src/chat/chat-context.ts +7 -1
- package/src/chat/chat-helpers.ts +49 -0
- package/src/chat/chat-state.ts +17 -6
- package/src/chat/icons.tsx +28 -0
- package/src/chat/model-copy.ts +41 -0
- package/src/chat/pending-files.ts +236 -0
- package/src/chat/side-width.ts +48 -0
- package/src/chrome/AppShell.tsx +9 -1
- package/src/chrome/CommandPalette.tsx +7 -0
- package/src/chrome/ContentExplorerSidebar.tsx +43 -74
- package/src/chrome/folder-create-context.ts +56 -11
- package/src/chrome/hotkeys.ts +8 -0
- package/src/fields/FieldControl.tsx +331 -115
- package/src/fields/LinkFieldInput.tsx +13 -6
- package/src/fields/array-item-title.ts +28 -0
- package/src/fields/field-label.ts +8 -0
- package/src/host-pointer.ts +2 -0
- package/src/install-preview-pointer.ts +1 -0
- package/src/pages/BlockPicker.tsx +362 -0
- package/src/pages/BlocksList.tsx +39 -67
- package/src/pages/CliAuthorizePage.tsx +138 -25
- package/src/pages/DocEditorPage.tsx +95 -18
- package/src/pages/EmbedPublishPage.tsx +40 -2
- package/src/pages/LoginPage.tsx +118 -31
- package/src/pages/SettingsSchemaPage.tsx +19 -3
- package/src/pages/WorkspaceLayout.tsx +16 -1
- package/src/pages/block-picker.ts +116 -0
- package/src/pages/editor-grab.ts +61 -13
- package/src/pages/preview-split.ts +24 -0
- package/src/pages/session-preview.ts +1 -0
- package/src/replica/types.ts +2 -0
- package/src/sign-in-link.ts +45 -0
- package/src/site-pointer.ts +14 -1
- package/src/site-widget.tsx +12 -1
- package/src/ui/Field.tsx +26 -0
- package/src/workspace/schema-source.tsx +126 -0
- package/dist/chunks/dashboard-DeNgythd.js +0 -1779
- package/src/site-devbar-overlay-inject.ts +0 -15
- package/src/site-publish-menu.tsx +0 -33
|
@@ -1,45 +1,122 @@
|
|
|
1
1
|
// packages/studio/src/pages/CliAuthorizePage.tsx
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import { useSearchParams } from "react-router";
|
|
4
4
|
import * as stylex from "@stylexjs/stylex";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
approveCliLogin,
|
|
7
|
+
fetchAllWorkspaces,
|
|
8
|
+
fetchCliLoginRequest,
|
|
9
|
+
type CliLoginRequest,
|
|
10
|
+
type WorkspaceSummary,
|
|
11
|
+
} from "../api";
|
|
6
12
|
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
7
13
|
import { Button } from "../ui/Button";
|
|
8
14
|
import { Text } from "../ui/Text";
|
|
9
15
|
|
|
16
|
+
type Loaded = { request: CliLoginRequest; workspaces: WorkspaceSummary[] };
|
|
17
|
+
|
|
10
18
|
export function CliAuthorizePage({ email }: { email: string }) {
|
|
11
19
|
const [params] = useSearchParams();
|
|
12
20
|
const id = params.get("id") ?? "";
|
|
13
|
-
const [
|
|
21
|
+
const [loaded, setLoaded] = useState<Loaded | null>(null);
|
|
22
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
23
|
+
const [choice, setChoice] = useState<string>("");
|
|
24
|
+
const [status, setStatus] = useState<"idle" | "busy" | "done">("idle");
|
|
14
25
|
const [error, setError] = useState<string | null>(null);
|
|
15
26
|
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!id) {
|
|
29
|
+
setLoadError("This link has no login id. Run backmatter login again.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let live = true;
|
|
33
|
+
void Promise.all([fetchCliLoginRequest(id), fetchAllWorkspaces()])
|
|
34
|
+
.then(([request, { workspaces }]) => {
|
|
35
|
+
if (!live) return;
|
|
36
|
+
setLoaded({ request, workspaces });
|
|
37
|
+
setChoice(request.workspace?.id ?? (workspaces.length === 1 ? workspaces[0]!.id : ""));
|
|
38
|
+
})
|
|
39
|
+
.catch(() => {
|
|
40
|
+
if (live) setLoadError("This login has expired or was already used. Run backmatter login again.");
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
live = false;
|
|
44
|
+
};
|
|
45
|
+
}, [id]);
|
|
46
|
+
|
|
47
|
+
const chosen = loaded?.workspaces.find((ws) => ws.id === choice) ?? null;
|
|
48
|
+
|
|
16
49
|
return (
|
|
17
50
|
<main {...stylex.props(styles.screen)}>
|
|
18
51
|
<div {...stylex.props(styles.card)}>
|
|
19
52
|
<Text as="h1" size="xl" weight="medium">
|
|
20
53
|
Allow the CLI
|
|
21
54
|
</Text>
|
|
22
|
-
<Text tone="
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
{loadError ? <Text tone="danger">{loadError}</Text> : null}
|
|
56
|
+
{!loaded && !loadError ? <Text tone="muted">Loading…</Text> : null}
|
|
57
|
+
{loaded && status === "done" ? (
|
|
58
|
+
<Text>
|
|
59
|
+
The CLI is signed in to {chosen?.name ?? "the workspace"}. You can return to the terminal.
|
|
60
|
+
</Text>
|
|
61
|
+
) : null}
|
|
62
|
+
{loaded && status !== "done" ? (
|
|
63
|
+
<>
|
|
64
|
+
<div {...stylex.props(styles.code)}>
|
|
65
|
+
<Text tone="muted" size="sm">
|
|
66
|
+
Confirm this code matches your terminal
|
|
67
|
+
{loaded.request.client ? ` on ${loaded.request.client}` : ""}:
|
|
68
|
+
</Text>
|
|
69
|
+
<Text mono size="display" weight="semibold">
|
|
70
|
+
{loaded.request.userCode}
|
|
71
|
+
</Text>
|
|
72
|
+
</div>
|
|
73
|
+
<Text tone="muted">
|
|
74
|
+
If you did not just run backmatter login, close this page.
|
|
75
|
+
</Text>
|
|
76
|
+
{loaded.request.workspace ? (
|
|
77
|
+
<Text>
|
|
78
|
+
The CLI can act as {email} in <strong>{loaded.request.workspace.name}</strong>, and only there.
|
|
79
|
+
</Text>
|
|
80
|
+
) : loaded.workspaces.length === 0 ? (
|
|
81
|
+
<Text tone="danger">You are not a member of any workspace yet.</Text>
|
|
82
|
+
) : (
|
|
83
|
+
<fieldset {...stylex.props(styles.fieldset)}>
|
|
84
|
+
<legend {...stylex.props(styles.legend)}>
|
|
85
|
+
The CLI can act as {email} in one workspace. Which one?
|
|
86
|
+
</legend>
|
|
87
|
+
{loaded.workspaces.map((ws) => (
|
|
88
|
+
<label key={ws.id} {...stylex.props(styles.option)}>
|
|
89
|
+
<input
|
|
90
|
+
type="radio"
|
|
91
|
+
name="workspace"
|
|
92
|
+
value={ws.id}
|
|
93
|
+
checked={choice === ws.id}
|
|
94
|
+
onChange={() => setChoice(ws.id)}
|
|
95
|
+
/>
|
|
96
|
+
<span>{ws.name}</span>
|
|
97
|
+
<span {...stylex.props(styles.slug)}>{ws.slug}</span>
|
|
98
|
+
</label>
|
|
99
|
+
))}
|
|
100
|
+
</fieldset>
|
|
101
|
+
)}
|
|
102
|
+
{error ? <Text tone="danger">{error}</Text> : null}
|
|
103
|
+
<Button
|
|
104
|
+
disabled={!choice || status === "busy"}
|
|
105
|
+
onClick={() => {
|
|
106
|
+
setError(null);
|
|
107
|
+
setStatus("busy");
|
|
108
|
+
void approveCliLogin(id, choice)
|
|
109
|
+
.then(() => setStatus("done"))
|
|
110
|
+
.catch((err: unknown) => {
|
|
111
|
+
setStatus("idle");
|
|
112
|
+
setError(err instanceof Error ? err.message : "Could not approve");
|
|
113
|
+
});
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{chosen ? `Allow in ${chosen.name}` : "Allow"}
|
|
117
|
+
</Button>
|
|
118
|
+
</>
|
|
119
|
+
) : null}
|
|
43
120
|
</div>
|
|
44
121
|
</main>
|
|
45
122
|
);
|
|
@@ -60,7 +137,7 @@ const styles = stylex.create({
|
|
|
60
137
|
card: {
|
|
61
138
|
display: "flex",
|
|
62
139
|
width: "100%",
|
|
63
|
-
maxWidth: "
|
|
140
|
+
maxWidth: "360px",
|
|
64
141
|
flexDirection: "column",
|
|
65
142
|
alignItems: "flex-start",
|
|
66
143
|
gap: space.lg,
|
|
@@ -73,4 +150,40 @@ const styles = stylex.create({
|
|
|
73
150
|
padding: space.xxl,
|
|
74
151
|
fontSize: type.sm,
|
|
75
152
|
},
|
|
153
|
+
code: {
|
|
154
|
+
display: "flex",
|
|
155
|
+
flexDirection: "column",
|
|
156
|
+
gap: space.xs,
|
|
157
|
+
width: "100%",
|
|
158
|
+
boxSizing: "border-box",
|
|
159
|
+
padding: space.lg,
|
|
160
|
+
borderRadius: radius.md,
|
|
161
|
+
backgroundColor: colors.bgPanel,
|
|
162
|
+
},
|
|
163
|
+
fieldset: {
|
|
164
|
+
display: "flex",
|
|
165
|
+
flexDirection: "column",
|
|
166
|
+
gap: space.sm,
|
|
167
|
+
width: "100%",
|
|
168
|
+
margin: 0,
|
|
169
|
+
padding: 0,
|
|
170
|
+
borderWidth: 0,
|
|
171
|
+
},
|
|
172
|
+
legend: {
|
|
173
|
+
padding: 0,
|
|
174
|
+
marginBottom: space.sm,
|
|
175
|
+
fontSize: type.md,
|
|
176
|
+
},
|
|
177
|
+
option: {
|
|
178
|
+
display: "flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
gap: space.md,
|
|
181
|
+
fontSize: type.md,
|
|
182
|
+
cursor: "pointer",
|
|
183
|
+
},
|
|
184
|
+
slug: {
|
|
185
|
+
color: colors.textMuted,
|
|
186
|
+
fontFamily: type.mono,
|
|
187
|
+
fontSize: type.xs,
|
|
188
|
+
},
|
|
76
189
|
});
|
|
@@ -48,9 +48,12 @@ import {
|
|
|
48
48
|
PREVIEW_PCT_MIN,
|
|
49
49
|
WIDE_QUERY,
|
|
50
50
|
clampPreviewPct,
|
|
51
|
+
persistEditorHidden,
|
|
51
52
|
persistPreviewPct,
|
|
53
|
+
readEditorHidden,
|
|
52
54
|
readPreviewPct,
|
|
53
55
|
} from "./preview-split";
|
|
56
|
+
import { DockRightIcon } from "../chat/icons";
|
|
54
57
|
import { routesForContentFiles } from "../content-routes";
|
|
55
58
|
import { PreviewAddress } from "./PreviewAddress";
|
|
56
59
|
import { PreviewSizeSwitch, PreviewViewport } from "./PreviewSize";
|
|
@@ -71,13 +74,12 @@ import { blocksFromFrontmatter } from "./blocks-list";
|
|
|
71
74
|
import type { WorkspaceOutletContext } from "../workspace/types";
|
|
72
75
|
import { contentDocPath, settingsPath } from "../workspace-path";
|
|
73
76
|
import { bindPreviewEditor, previewFrameTransport } from "./preview-bridge";
|
|
74
|
-
import { editorGrabAction } from "./editor-grab";
|
|
77
|
+
import { editorGrabAction, editorHelloAction } from "./editor-grab";
|
|
75
78
|
import { useChatUI } from "../chat/ChatProvider";
|
|
76
79
|
import { POINTER_ARM_EVENT } from "../chat/pointer-arm";
|
|
77
80
|
import { registerPreviewHighlight } from "../preview-highlight";
|
|
78
81
|
import {
|
|
79
82
|
createWindowPreviewTransport,
|
|
80
|
-
samePreviewRef,
|
|
81
83
|
type PreviewChannelRef,
|
|
82
84
|
type PreviewGrabMessage,
|
|
83
85
|
} from "@backmatter/core/preview";
|
|
@@ -202,12 +204,15 @@ export function DocEditorPage() {
|
|
|
202
204
|
const [previewLive, setPreviewLive] = useState<"rendered" | "error" | null>(null);
|
|
203
205
|
const [previewPct, setPreviewPct] = useState(readPreviewPct);
|
|
204
206
|
const [previewSize, setPreviewSize] = useState(readPreviewSize);
|
|
207
|
+
const [editorHiddenPref, setEditorHiddenPref] = useState(readEditorHidden);
|
|
205
208
|
const [dragging, setDragging] = useState(false);
|
|
206
209
|
const [editEpoch, setEditEpoch] = useState(0);
|
|
207
210
|
const [selection, setSelection] = useState<EditorSelection | null>(null);
|
|
208
211
|
const splitRef = useRef<HTMLDivElement>(null);
|
|
209
212
|
const previewFrameRef = useRef<HTMLIFrameElement>(null);
|
|
210
213
|
const previewSession = useRef<ReturnType<typeof bindPreviewEditor> | null>(null);
|
|
214
|
+
// Mirrors the composer's crosshair so a reloaded preview can be armed again.
|
|
215
|
+
const pointerArmed = useRef(false);
|
|
211
216
|
const { addPointer, setPreviewPointer, setPointerHighlight } = useChatUI();
|
|
212
217
|
const [blockFocus, setBlockFocus] = useState<{ id: string; nonce: number } | null>(null);
|
|
213
218
|
const blockFocusNonce = useRef(0);
|
|
@@ -341,27 +346,31 @@ export function DocEditorPage() {
|
|
|
341
346
|
}, [previewUrl]);
|
|
342
347
|
|
|
343
348
|
function onPreviewHello(hello: PreviewChannelRef, capabilities?: string[]) {
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
349
|
+
const action = editorHelloAction({
|
|
350
|
+
hello,
|
|
351
|
+
openRef: channelRef.current,
|
|
352
|
+
capabilities,
|
|
353
|
+
armed: pointerArmed.current,
|
|
354
|
+
});
|
|
355
|
+
setPreviewPointer(action.canPoint);
|
|
356
|
+
if (action.rearm) previewSession.current?.point(true);
|
|
357
|
+
if (action.disarm) {
|
|
358
|
+
window.dispatchEvent(new CustomEvent(POINTER_ARM_EVENT, { detail: { on: false } }));
|
|
359
|
+
}
|
|
348
360
|
}
|
|
349
361
|
|
|
350
362
|
function onPreviewGrab(grab: PreviewGrabMessage) {
|
|
351
|
-
if (typeof grab.blockId !== "string" || !grab.blockId) return;
|
|
352
|
-
const ids = blocksFromFrontmatter(latest.current.frontmatter[blocksFieldRef.current]).map(
|
|
353
|
-
(block) => block.id,
|
|
354
|
-
);
|
|
355
363
|
const decision = editorGrabAction({
|
|
356
364
|
grabRef: grab.ref,
|
|
357
365
|
openRef: channelRef.current,
|
|
358
|
-
|
|
366
|
+
blocks: blocksFromFrontmatter(latest.current.frontmatter[blocksFieldRef.current]),
|
|
359
367
|
grab: {
|
|
360
368
|
blockId: grab.blockId,
|
|
361
369
|
blockType: grab.blockType,
|
|
362
370
|
blockIndex: grab.blockIndex,
|
|
363
371
|
quote: grab.quote,
|
|
364
372
|
shift: grab.shift,
|
|
373
|
+
...(grab.field ? { field: grab.field } : {}),
|
|
365
374
|
},
|
|
366
375
|
});
|
|
367
376
|
if (decision.action === "add") {
|
|
@@ -372,6 +381,7 @@ export function DocEditorPage() {
|
|
|
372
381
|
blockType: decision.blockType,
|
|
373
382
|
blockIndex: decision.blockIndex,
|
|
374
383
|
quote: decision.quote,
|
|
384
|
+
...(decision.field ? { field: decision.field } : {}),
|
|
375
385
|
});
|
|
376
386
|
}
|
|
377
387
|
if (decision.action === "open") {
|
|
@@ -470,6 +480,7 @@ export function DocEditorPage() {
|
|
|
470
480
|
useEffect(() => {
|
|
471
481
|
function onArm(event: Event) {
|
|
472
482
|
const on = (event as CustomEvent<{ on?: boolean }>).detail?.on === true;
|
|
483
|
+
pointerArmed.current = on;
|
|
473
484
|
previewSession.current?.point(on);
|
|
474
485
|
}
|
|
475
486
|
window.addEventListener(POINTER_ARM_EVENT, onArm);
|
|
@@ -510,6 +521,13 @@ export function DocEditorPage() {
|
|
|
510
521
|
setBrowse({ doc: docIdentity, path: next });
|
|
511
522
|
}
|
|
512
523
|
|
|
524
|
+
function toggleEditor() {
|
|
525
|
+
setEditorHiddenPref((hidden) => {
|
|
526
|
+
persistEditorHidden(!hidden);
|
|
527
|
+
return !hidden;
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
513
531
|
function choosePreviewSize(size: PreviewSize) {
|
|
514
532
|
setPreviewSize(size);
|
|
515
533
|
persistPreviewSize(size);
|
|
@@ -584,7 +602,7 @@ export function DocEditorPage() {
|
|
|
584
602
|
return names;
|
|
585
603
|
}
|
|
586
604
|
|
|
587
|
-
async function reload() {
|
|
605
|
+
async function reload(changed = false) {
|
|
588
606
|
try {
|
|
589
607
|
const data = await fetchDoc(workspaceId, type, slug);
|
|
590
608
|
hydrated.current = false;
|
|
@@ -595,7 +613,9 @@ export function DocEditorPage() {
|
|
|
595
613
|
setFrontmatter(data.doc.frontmatter);
|
|
596
614
|
setBody(data.doc.body);
|
|
597
615
|
latest.current = { frontmatter: data.doc.frontmatter, body: data.doc.body };
|
|
598
|
-
|
|
616
|
+
// A reload after an agent write, an undo, or a branch move. The preview
|
|
617
|
+
// follows the editor once it has sent a document, so send this one too.
|
|
618
|
+
if (embed || changed) previewSession.current?.setDoc(latest.current);
|
|
599
619
|
applyModelFields(
|
|
600
620
|
data.doc.model?.fields,
|
|
601
621
|
Object.keys(data.doc.frontmatter),
|
|
@@ -659,7 +679,7 @@ export function DocEditorPage() {
|
|
|
659
679
|
function onChanged() {
|
|
660
680
|
saveGen.current += 1;
|
|
661
681
|
hydrated.current = false;
|
|
662
|
-
void reload().catch((err: Error) => setError(err.message));
|
|
682
|
+
void reload(true).catch((err: Error) => setError(err.message));
|
|
663
683
|
}
|
|
664
684
|
function onDocChanged(e: Event) {
|
|
665
685
|
const detail = (e as CustomEvent<DocChangedDetail>).detail;
|
|
@@ -721,7 +741,7 @@ export function DocEditorPage() {
|
|
|
721
741
|
if (wasAiEditing.current && !aiEditing) {
|
|
722
742
|
saveGen.current += 1;
|
|
723
743
|
hydrated.current = false;
|
|
724
|
-
void reload().catch((err: Error) => setError(err.message));
|
|
744
|
+
void reload(true).catch((err: Error) => setError(err.message));
|
|
725
745
|
}
|
|
726
746
|
wasAiEditing.current = aiEditing;
|
|
727
747
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -881,7 +901,9 @@ export function DocEditorPage() {
|
|
|
881
901
|
}
|
|
882
902
|
|
|
883
903
|
const inConflict = docStatus === "conflict";
|
|
884
|
-
|
|
904
|
+
// Hiding the editor only makes sense when there is a preview to show instead.
|
|
905
|
+
const editorHidden = showPreview && editorHiddenPref;
|
|
906
|
+
const previewSx = stylex.props(styles.preview, editorHidden && styles.previewSolo);
|
|
885
907
|
|
|
886
908
|
return (
|
|
887
909
|
<div {...stylex.props(styles.root)}>
|
|
@@ -902,7 +924,7 @@ export function DocEditorPage() {
|
|
|
902
924
|
<>
|
|
903
925
|
<aside
|
|
904
926
|
className={previewSx.className}
|
|
905
|
-
style={{ ...previewSx.style, flexBasis: `${previewPct}%` }}
|
|
927
|
+
style={editorHidden ? previewSx.style : { ...previewSx.style, flexBasis: `${previewPct}%` }}
|
|
906
928
|
>
|
|
907
929
|
<div {...stylex.props(styles.previewBar)}>
|
|
908
930
|
<div {...stylex.props(styles.previewLead)}>
|
|
@@ -940,6 +962,17 @@ export function DocEditorPage() {
|
|
|
940
962
|
/>
|
|
941
963
|
<div {...stylex.props(styles.sizeSwitch)}>
|
|
942
964
|
<PreviewSizeSwitch size={previewSize} onSize={choosePreviewSize} />
|
|
965
|
+
<Tooltip label={editorHidden ? "Show editor" : "Hide editor"}>
|
|
966
|
+
<button
|
|
967
|
+
type="button"
|
|
968
|
+
aria-label={editorHidden ? "Show editor" : "Hide editor"}
|
|
969
|
+
aria-pressed={!editorHidden}
|
|
970
|
+
onClick={toggleEditor}
|
|
971
|
+
{...stylex.props(styles.editorToggle, !editorHidden && styles.editorToggleOn)}
|
|
972
|
+
>
|
|
973
|
+
<DockRightIcon size={14} />
|
|
974
|
+
</button>
|
|
975
|
+
</Tooltip>
|
|
943
976
|
</div>
|
|
944
977
|
</div>
|
|
945
978
|
{previewUrl ? (
|
|
@@ -980,6 +1013,7 @@ export function DocEditorPage() {
|
|
|
980
1013
|
)}
|
|
981
1014
|
</aside>
|
|
982
1015
|
|
|
1016
|
+
{editorHidden ? null : (
|
|
983
1017
|
<div
|
|
984
1018
|
role="separator"
|
|
985
1019
|
aria-orientation={wide ? "vertical" : "horizontal"}
|
|
@@ -998,10 +1032,15 @@ export function DocEditorPage() {
|
|
|
998
1032
|
>
|
|
999
1033
|
<span {...stylex.props(styles.handleHit)} />
|
|
1000
1034
|
</div>
|
|
1035
|
+
)}
|
|
1001
1036
|
</>
|
|
1002
1037
|
) : null}
|
|
1003
1038
|
|
|
1004
|
-
|
|
1039
|
+
{/* Hidden with CSS, not unmounted, so unsaved edits survive the toggle. */}
|
|
1040
|
+
<section
|
|
1041
|
+
aria-hidden={editorHidden || undefined}
|
|
1042
|
+
{...stylex.props(styles.editor, editorHidden && styles.editorHidden)}
|
|
1043
|
+
>
|
|
1005
1044
|
<div {...stylex.props(styles.editorColumn, !showPreview && styles.editorColumnSolo)}>
|
|
1006
1045
|
<div {...stylex.props(styles.toolbar)}>
|
|
1007
1046
|
<h1 {...stylex.props(styles.docTitle)}>
|
|
@@ -1107,6 +1146,7 @@ export function DocEditorPage() {
|
|
|
1107
1146
|
objects={objects}
|
|
1108
1147
|
documentLists={documentLists}
|
|
1109
1148
|
readOnly={blocksReadOnly}
|
|
1149
|
+
siteUrl={siteUrl}
|
|
1110
1150
|
onChange={onBlocksChange}
|
|
1111
1151
|
/>
|
|
1112
1152
|
)}
|
|
@@ -1128,6 +1168,7 @@ export function DocEditorPage() {
|
|
|
1128
1168
|
documentLists={documentLists}
|
|
1129
1169
|
readOnly={aiEditing || parseFailed}
|
|
1130
1170
|
focusBlock={blockFocus}
|
|
1171
|
+
siteUrl={siteUrl}
|
|
1131
1172
|
onChange={(next) => {
|
|
1132
1173
|
markEdited();
|
|
1133
1174
|
setFrontmatter((prev) => ({ ...prev, [blocksField]: next }));
|
|
@@ -1231,8 +1272,44 @@ const styles = stylex.create({
|
|
|
1231
1272
|
overflow: "hidden",
|
|
1232
1273
|
},
|
|
1233
1274
|
sizeSwitch: {
|
|
1275
|
+
display: "flex",
|
|
1276
|
+
alignItems: "center",
|
|
1277
|
+
gap: space.sm,
|
|
1234
1278
|
justifySelf: "end",
|
|
1235
1279
|
},
|
|
1280
|
+
previewSolo: {
|
|
1281
|
+
flexGrow: 1,
|
|
1282
|
+
flexShrink: 1,
|
|
1283
|
+
flexBasis: "auto",
|
|
1284
|
+
},
|
|
1285
|
+
editorHidden: {
|
|
1286
|
+
display: "none",
|
|
1287
|
+
},
|
|
1288
|
+
editorToggle: {
|
|
1289
|
+
display: "inline-flex",
|
|
1290
|
+
alignItems: "center",
|
|
1291
|
+
justifyContent: "center",
|
|
1292
|
+
width: 26,
|
|
1293
|
+
height: 26,
|
|
1294
|
+
padding: 0,
|
|
1295
|
+
borderWidth: 0,
|
|
1296
|
+
borderRadius: radius.md,
|
|
1297
|
+
color: colors.textMuted,
|
|
1298
|
+
backgroundColor: "transparent",
|
|
1299
|
+
cursor: "pointer",
|
|
1300
|
+
[hover]: {
|
|
1301
|
+
":hover": { color: colors.text, backgroundColor: colors.bgHover },
|
|
1302
|
+
},
|
|
1303
|
+
":focus-visible": {
|
|
1304
|
+
outlineWidth: 2,
|
|
1305
|
+
outlineStyle: "solid",
|
|
1306
|
+
outlineColor: colors.focus,
|
|
1307
|
+
outlineOffset: 1,
|
|
1308
|
+
},
|
|
1309
|
+
},
|
|
1310
|
+
editorToggleOn: {
|
|
1311
|
+
color: colors.text,
|
|
1312
|
+
},
|
|
1236
1313
|
previewLive: {
|
|
1237
1314
|
flexShrink: 0,
|
|
1238
1315
|
color: colors.textMuted,
|
|
@@ -69,6 +69,8 @@ export function EmbedPublishPage({
|
|
|
69
69
|
const [commitFailure, setCommitFailure] = useState<CommitErrorView | null>(null);
|
|
70
70
|
const [committing, setCommitting] = useState(false);
|
|
71
71
|
const [resolvingKey, setResolvingKey] = useState<string | null>(null);
|
|
72
|
+
const [gitError, setGitError] = useState<string | null>(null);
|
|
73
|
+
const [attempt, setAttempt] = useState(0);
|
|
72
74
|
|
|
73
75
|
useEffect(() => {
|
|
74
76
|
let stop = false;
|
|
@@ -94,6 +96,7 @@ export function EmbedPublishPage({
|
|
|
94
96
|
.then((next) => {
|
|
95
97
|
if (stop) return;
|
|
96
98
|
setGit(next);
|
|
99
|
+
setGitError(null);
|
|
97
100
|
const changeCount = next.changes.length;
|
|
98
101
|
const conflictCount = countConflicts(next);
|
|
99
102
|
onStatusRef.current?.({ changeCount, conflictCount });
|
|
@@ -105,7 +108,7 @@ export function EmbedPublishPage({
|
|
|
105
108
|
);
|
|
106
109
|
})
|
|
107
110
|
.catch((err: unknown) => {
|
|
108
|
-
if (!stop)
|
|
111
|
+
if (!stop) setGitError(err instanceof Error ? err.message : "Git status failed");
|
|
109
112
|
});
|
|
110
113
|
};
|
|
111
114
|
load();
|
|
@@ -114,7 +117,7 @@ export function EmbedPublishPage({
|
|
|
114
117
|
stop = true;
|
|
115
118
|
window.clearInterval(timer);
|
|
116
119
|
};
|
|
117
|
-
}, [workspaceId]);
|
|
120
|
+
}, [workspaceId, attempt]);
|
|
118
121
|
|
|
119
122
|
const changes = git?.changes ?? [];
|
|
120
123
|
const conflictCount = countConflicts(git);
|
|
@@ -178,6 +181,38 @@ export function EmbedPublishPage({
|
|
|
178
181
|
|
|
179
182
|
const branch = git?.currentBranch ?? "main";
|
|
180
183
|
|
|
184
|
+
// Until the first status read lands, the panel cannot say what is pending.
|
|
185
|
+
if (!git) {
|
|
186
|
+
return (
|
|
187
|
+
<div {...stylex.props(styles.form)}>
|
|
188
|
+
{gitError ? (
|
|
189
|
+
<>
|
|
190
|
+
<p {...stylex.props(popup.groupLabel)}>Could not load changes</p>
|
|
191
|
+
<p role="alert" {...stylex.props(styles.error)}>
|
|
192
|
+
{gitError}
|
|
193
|
+
</p>
|
|
194
|
+
<div {...stylex.props(styles.footer)}>
|
|
195
|
+
<button
|
|
196
|
+
type="button"
|
|
197
|
+
onClick={() => {
|
|
198
|
+
setGitError(null);
|
|
199
|
+
setAttempt((n) => n + 1);
|
|
200
|
+
}}
|
|
201
|
+
{...stylex.props(styles.conflictBtn)}
|
|
202
|
+
>
|
|
203
|
+
Try again
|
|
204
|
+
</button>
|
|
205
|
+
</div>
|
|
206
|
+
</>
|
|
207
|
+
) : (
|
|
208
|
+
<p role="status" {...stylex.props(popup.groupLabel, styles.loading)}>
|
|
209
|
+
Loading changes…
|
|
210
|
+
</p>
|
|
211
|
+
)}
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
181
216
|
if (conflicts.length > 0) {
|
|
182
217
|
return (
|
|
183
218
|
<div {...stylex.props(styles.form)}>
|
|
@@ -400,6 +435,9 @@ const styles = stylex.create({
|
|
|
400
435
|
},
|
|
401
436
|
},
|
|
402
437
|
},
|
|
438
|
+
loading: {
|
|
439
|
+
paddingBottom: space.md,
|
|
440
|
+
},
|
|
403
441
|
hint: {
|
|
404
442
|
margin: 0,
|
|
405
443
|
paddingInline: space.lg,
|