@kabmo-labs/kabmo 0.9.0 → 0.10.0
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 +45 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +333 -333
- package/dist/client/static/js/index-18xe7655.css +1 -0
- package/dist/client/static/js/{index-bpptfkz2.js → index-nxpe7835.js} +768 -763
- package/package.json +3 -1
- package/src/client/components/common/code-surface/bracket-guide.test.ts +249 -0
- package/src/client/components/common/code-surface/bracket-guide.ts +131 -0
- package/src/client/components/common/code-surface/documents.test.ts +5 -3
- package/src/client/components/common/code-surface/documents.ts +85 -0
- package/src/client/components/common/code-surface/extensions.test.ts +5 -0
- package/src/client/components/common/code-surface/extensions.ts +140 -7
- package/src/client/components/common/code-surface/fold-stack.test.ts +218 -0
- package/src/client/components/common/code-surface/fold.test.ts +148 -0
- package/src/client/components/common/code-surface/fold.ts +118 -0
- package/src/client/components/common/code-surface/indent-guide.ts +104 -0
- package/src/client/components/common/code-surface/indent.test.ts +239 -0
- package/src/client/components/common/code-surface/indent.ts +124 -0
- package/src/client/components/common/code-surface/index.tsx +76 -46
- package/src/client/components/common/code-surface/keymap.ts +12 -23
- package/src/client/components/common/code-surface/line-commands.test.ts +90 -0
- package/src/client/components/common/code-surface/line-commands.ts +103 -0
- package/src/client/components/common/code-surface/props.ts +87 -0
- package/src/client/components/common/code-surface/stream-language.test.ts +118 -0
- package/src/client/components/common/code-surface/stream-language.ts +123 -0
- package/src/client/components/common/code-surface/theme.test.ts +40 -5
- package/src/client/components/common/code-surface/theme.ts +113 -0
- package/src/client/components/common/code-surface/typing.test.ts +97 -0
- package/src/client/components/common/code-surface/typing.ts +111 -0
- package/src/client/components/common/toolbar-row/index.test.tsx +53 -4
- package/src/client/components/common/toolbar-row/index.tsx +101 -30
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +17 -0
- package/src/client/components/layout/desktop-layout/index.tsx +18 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +35 -33
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +20 -1
- package/src/client/components/mobile/mobile-right-sidebar/editor-props.ts +25 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/appearance-settings/EditorIndentSection.tsx +87 -0
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +99 -0
- package/src/client/components/workspace/chat-timeline/chat-input/expansion.ts +9 -4
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +15 -11
- package/src/client/components/workspace/chat-timeline/chat-input/stretch-send.test.tsx +165 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +17 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +10 -6
- package/src/client/components/workspace/editor/Body.tsx +24 -0
- package/src/client/components/workspace/editor/CommandPalette.tsx +4 -4
- package/src/client/components/workspace/editor/ConflictStrip.tsx +77 -0
- package/src/client/components/workspace/editor/Dialogs.tsx +53 -0
- package/src/client/components/workspace/editor/EmptyEditor.tsx +23 -0
- package/src/client/components/workspace/editor/ExternalChangeStrip.tsx +61 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +89 -1
- package/src/client/components/workspace/editor/FilePane.tsx +43 -0
- package/src/client/components/workspace/editor/FindWidget.test.ts +9 -5
- package/src/client/components/workspace/editor/FindWidget.tsx +29 -0
- package/src/client/components/workspace/editor/GoToLineModal.tsx +123 -0
- package/src/client/components/workspace/editor/Notices.tsx +71 -0
- package/src/client/components/workspace/editor/Pane.tsx +118 -0
- package/src/client/components/workspace/editor/PluginColumn.tsx +32 -0
- package/src/client/components/workspace/editor/QuickOpenModal.tsx +146 -0
- package/src/client/components/workspace/editor/SaveAsModal.tsx +175 -0
- package/src/client/components/workspace/editor/SplitColumn.tsx +98 -0
- package/src/client/components/workspace/editor/SplitPane.tsx +57 -0
- package/src/client/components/workspace/editor/StatusBar.tsx +106 -0
- package/src/client/components/workspace/editor/TabContextMenu.tsx +75 -0
- package/src/client/components/workspace/editor/Tabs.tsx +195 -18
- package/src/client/components/workspace/editor/Toolbar.tsx +54 -181
- package/src/client/components/workspace/editor/index.tsx +199 -189
- package/src/client/components/workspace/editor/props.ts +64 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +300 -0
- package/src/client/components/workspace/file-explorer/Modals.tsx +14 -1
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +2 -1
- package/src/client/components/workspace/file-explorer/clipboard.test.ts +3 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +61 -0
- package/src/client/components/workspace/file-explorer/index.tsx +10 -48
- package/src/client/components/workspace/file-explorer/local-edit.test.ts +8 -3
- package/src/client/components/workspace/search-panel/Body.tsx +6 -1
- package/src/client/hooks/chat/composer/file-drop.ts +22 -37
- package/src/client/hooks/chat/composer/pipeline.test.ts +76 -0
- package/src/client/hooks/chat/composer/pipeline.ts +12 -1
- package/src/client/hooks/editor/caret-position.test.ts +58 -0
- package/src/client/hooks/editor/caret-position.ts +48 -0
- package/src/client/hooks/editor/file-editor-types.ts +200 -0
- package/src/client/hooks/editor/find-history.test.ts +132 -0
- package/src/client/hooks/editor/find-history.ts +46 -0
- package/src/client/hooks/editor/find-selection-range.test.ts +100 -0
- package/src/client/hooks/editor/find-selection-range.ts +49 -0
- package/src/client/hooks/editor/find-state.ts +13 -0
- package/src/client/hooks/editor/font.test.ts +0 -93
- package/src/client/hooks/editor/indent-settings.test.ts +104 -0
- package/src/client/hooks/editor/indent-settings.ts +88 -0
- package/src/client/hooks/editor/quick-open.test.ts +141 -0
- package/src/client/hooks/editor/quick-open.ts +127 -0
- package/src/client/hooks/editor/save-as.test.ts +156 -0
- package/src/client/hooks/editor/save-as.ts +122 -0
- package/src/client/hooks/editor/save-file.test.ts +179 -0
- package/src/client/hooks/editor/save-file.ts +73 -28
- package/src/client/hooks/editor/typing-settings.test.ts +73 -0
- package/src/client/hooks/editor/typing-settings.ts +65 -0
- package/src/client/hooks/editor/use-close-guard.ts +98 -0
- package/src/client/hooks/editor/use-editor-drop-overlay.test.ts +159 -0
- package/src/client/hooks/editor/use-editor-drop.shell.test.ts +224 -0
- package/src/client/hooks/editor/use-editor-drop.ts +58 -68
- package/src/client/hooks/editor/use-editor-find.test.ts +2 -2
- package/src/client/hooks/editor/use-editor-find.ts +38 -3
- package/src/client/hooks/editor/use-editor-panel-keys.ts +152 -0
- package/src/client/hooks/editor/use-editor-tab-state.ts +71 -0
- package/src/client/hooks/editor/use-external-change-notice.ts +71 -0
- package/src/client/hooks/editor/use-external-change.test.ts +88 -0
- package/src/client/hooks/editor/use-external-change.ts +146 -0
- package/src/client/hooks/editor/use-file-editor.ts +83 -116
- package/src/client/hooks/editor/use-file-read.ts +16 -8
- package/src/client/hooks/editor/use-file-writes.ts +28 -3
- package/src/client/hooks/editor/use-mobile-editor-find.ts +69 -0
- package/src/client/hooks/editor/use-mobile-reveal.ts +53 -0
- package/src/client/hooks/editor/use-search-reveal-jump.ts +57 -0
- package/src/client/hooks/editor/use-split-editor.test.tsx +169 -0
- package/src/client/hooks/editor/use-split-editor.ts +91 -0
- package/src/client/hooks/editor/use-unload-guard.tsx +117 -0
- package/src/client/hooks/editor/use-write-conflict.test.ts +164 -0
- package/src/client/hooks/editor/use-write-conflict.ts +152 -0
- package/src/client/hooks/editor/wheel-zoom.test.ts +141 -0
- package/src/client/hooks/editor/wheel-zoom.ts +96 -0
- package/src/client/hooks/ui/drag-presence.test.ts +193 -0
- package/src/client/hooks/ui/drag-presence.ts +108 -0
- package/src/client/hooks/ui/settings-modal.test.ts +115 -0
- package/src/client/hooks/workspace/file-listing.ts +36 -24
- package/src/client/hooks/workspace/file-tabs.test.ts +90 -0
- package/src/client/hooks/workspace/file-tabs.ts +46 -0
- package/src/client/hooks/workspace/file-tree-edits.ts +103 -0
- package/src/client/lib/desktop/dropped-paths.ts +83 -0
- package/src/client/lib/editor/tab-menu.test.ts +127 -0
- package/src/client/lib/editor/tab-menu.ts +127 -0
- package/src/client/lib/editor-dirty-tabs.test.ts +102 -0
- package/src/client/lib/editor-dirty-tabs.ts +103 -0
- package/src/client/lib/native/resume.test.ts +66 -0
- package/src/client/lib/native/resume.ts +42 -0
- package/src/client/main.tsx +8 -0
- package/src/client/tailwind.css +38 -0
- package/src/server/lib/bundler/css.test.ts +31 -0
- package/src/server/lib/fs/listing.test.ts +81 -16
- package/src/server/lib/fs/listing.ts +72 -5
- package/src/server/lib/fs/write-conflict.test.ts +68 -0
- package/src/server/lib/fs/write-conflict.ts +84 -0
- package/src/server/routes/fs/action-save-as.test.ts +82 -0
- package/src/server/routes/fs/action.test.ts +82 -0
- package/src/server/routes/fs/action.ts +54 -1
- package/src/server/routes/fs/exists.ts +11 -1
- package/src/server/routes/fs/read.ts +6 -1
- package/src/shared/lib/code/editor/find-replace.test.ts +1 -1
- package/src/shared/lib/code/editor/find-scan.test.ts +1 -1
- package/src/shared/lib/code/editor/find-scan.ts +22 -1
- package/src/shared/lib/code/editor/find-selection.test.ts +56 -0
- package/src/shared/lib/code/editor/indent-guide-rule.test.ts +65 -0
- package/src/shared/lib/code/editor/indent-guide-rule.ts +47 -0
- package/src/shared/lib/code/editor/indent-rules.test.ts +219 -0
- package/src/shared/lib/code/editor/indent-rules.ts +198 -0
- package/src/shared/lib/code/editor/keymap.test.ts +23 -0
- package/src/shared/lib/code/editor/keymap.ts +40 -3
- package/src/shared/lib/code/editor/palette.test.ts +25 -2
- package/src/shared/lib/code/editor/palette.ts +10 -0
- package/src/shared/lib/code/editor/stream-modes.ts +225 -0
- package/src/shared/lib/code/syntax-highlight.test.ts +1 -1
- package/src/shared/lib/fs/file-tree.test.ts +41 -0
- package/src/shared/lib/fs/file-tree.ts +126 -34
- package/src/shared/lib/fs/folder-chain.test.ts +87 -0
- package/src/shared/lib/fs/folder-chain.ts +91 -0
- package/src/shared/lib/fs/fs-helpers.test.ts +4 -50
- package/src/shared/lib/realtime/connection.test.ts +5 -1
- package/src/shared/lib/realtime/connection.ts +25 -119
- package/src/shared/lib/realtime/frozen-recovery.test.ts +93 -0
- package/src/shared/lib/realtime/resume.ts +223 -0
- package/src/shared/lib/realtime/state.ts +22 -0
- package/src/shared/lib/realtime/watchdog-wiring.test.ts +224 -0
- package/src/shared/lib/realtime/watchdog.test.ts +99 -0
- package/src/shared/lib/realtime/watchdog.ts +72 -0
- package/src/shared/lib/workspace/split-editor.test.ts +104 -0
- package/src/shared/lib/workspace/split-editor.ts +129 -0
- package/src/test-support/file-explorer-disk.test-util.ts +30 -3
- package/src/test-support/pristine-globals.ts +7 -0
- package/dist/client/static/js/index-k315p1e8.css +0 -1
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
1
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
2
2
|
import type { RefObject } from 'preact';
|
|
3
3
|
import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
|
|
4
4
|
import { CodeSurface, type CodeSurfaceHandle } from '@/client/components/common/code-surface';
|
|
5
5
|
import { FindWidget } from '@/client/components/workspace/editor/FindWidget';
|
|
6
6
|
import { CommandPalette } from '@/client/components/workspace/editor/CommandPalette';
|
|
7
7
|
import { useScrollRestore } from '@/client/hooks/editor/use-scroll-restore';
|
|
8
|
+
import { indentUnitFor, useEditorIndent } from '@/client/hooks/editor/indent-settings';
|
|
9
|
+
import { useEditorTyping } from '@/client/hooks/editor/typing-settings';
|
|
10
|
+
import { EditorStatusBar } from '@/client/components/workspace/editor/StatusBar';
|
|
11
|
+
import { useWheelZoom } from '@/client/hooks/editor/wheel-zoom';
|
|
12
|
+
import { GoToLineModal } from '@/client/components/workspace/editor/GoToLineModal';
|
|
13
|
+
import { QuickOpenModal } from '@/client/components/workspace/editor/QuickOpenModal';
|
|
14
|
+
import type { CaretPosition } from '@/client/hooks/editor/caret-position';
|
|
15
|
+
import { lineStartOffset } from '@/shared/lib/code/editor/lines';
|
|
8
16
|
import type { UseFileEditorResult } from '@/client/hooks/editor/use-file-editor';
|
|
9
17
|
import type { EditorFindState } from '@/client/hooks/editor/use-editor-find';
|
|
10
18
|
import { EDITOR_LINE_HEIGHT } from '@/shared/lib/code/editor/typography';
|
|
@@ -19,9 +27,19 @@ interface FileDocumentProps {
|
|
|
19
27
|
surfaceRef: RefObject<CodeSurfaceHandle>;
|
|
20
28
|
paletteOpen: boolean;
|
|
21
29
|
onClosePalette: () => void;
|
|
30
|
+
/** Bumped when the user asks for "go to line"; a counter, so one bump is one open. */
|
|
31
|
+
goToLineRequest: number;
|
|
32
|
+
/** The file picker is open. */
|
|
33
|
+
quickOpen: boolean;
|
|
34
|
+
onCloseQuickOpen: () => void;
|
|
35
|
+
onOpenPath?: (path: string) => void;
|
|
36
|
+
rootPath?: string | null;
|
|
37
|
+
repoPath?: string | null;
|
|
22
38
|
onRunCommand: (command: EditorCommand) => void;
|
|
23
39
|
wordWrap: boolean;
|
|
24
40
|
zoomLevel: number;
|
|
41
|
+
/** The setter, so ⌘/Ctrl + wheel can zoom without a second source of truth. */
|
|
42
|
+
setZoomLevel: (update: (current: number) => number) => void;
|
|
25
43
|
editorFontFamily: string;
|
|
26
44
|
editorTheme: EditorThemeState;
|
|
27
45
|
/** The surface this file's kind is drawn by (see `document-kind`). */
|
|
@@ -53,9 +71,16 @@ export function FileDocument({
|
|
|
53
71
|
surfaceRef,
|
|
54
72
|
paletteOpen,
|
|
55
73
|
onClosePalette,
|
|
74
|
+
goToLineRequest,
|
|
75
|
+
quickOpen,
|
|
76
|
+
onCloseQuickOpen,
|
|
77
|
+
onOpenPath,
|
|
78
|
+
rootPath = null,
|
|
79
|
+
repoPath = null,
|
|
56
80
|
onRunCommand,
|
|
57
81
|
wordWrap,
|
|
58
82
|
zoomLevel,
|
|
83
|
+
setZoomLevel,
|
|
59
84
|
editorFontFamily,
|
|
60
85
|
editorTheme,
|
|
61
86
|
viewerKind,
|
|
@@ -66,12 +91,27 @@ export function FileDocument({
|
|
|
66
91
|
// SVG picture are drawn by the viewer dispatch instead (they replace the code
|
|
67
92
|
// surface rather than living inside its scroller).
|
|
68
93
|
const isMd = viewerKind === 'markdown';
|
|
94
|
+
// One indentation level, from the settings blob. Read here rather than passed
|
|
95
|
+
// down: the setting is a live event, and a prop captured at boot would not reach
|
|
96
|
+
// an editor that is already open.
|
|
97
|
+
const editorIndent = useEditorIndent();
|
|
98
|
+
const editorTyping = useEditorTyping();
|
|
99
|
+
const [caret, setCaret] = useState<CaretPosition | null>(null);
|
|
100
|
+
const [goToLineOpen, setGoToLineOpen] = useState(false);
|
|
101
|
+
// The request is a COUNTER: the dialog closes itself, and a boolean would need a
|
|
102
|
+
// matching "closed" write from this component to the panel that owns the chord.
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (goToLineRequest > 0) setGoToLineOpen(true);
|
|
105
|
+
}, [goToLineRequest]);
|
|
69
106
|
/**
|
|
70
107
|
* The code surface's scroller, which belongs to CodeMirror and appears only
|
|
71
108
|
* once its view mounts. Reported through `onScroller` because a `ref` cannot
|
|
72
109
|
* reach a node the component does not render.
|
|
73
110
|
*/
|
|
74
111
|
const [codeScroller, setCodeScroller] = useState<HTMLElement | null>(null);
|
|
112
|
+
// ⌘/Ctrl + wheel, and a trackpad pinch, clamped to the toolbar's own bounds. Armed on
|
|
113
|
+
// the render the scroller arrives in: it exists only once the view mounts.
|
|
114
|
+
useWheelZoom(codeScroller, setZoomLevel);
|
|
75
115
|
// The document owns its scroller, so it remembers where the reader left it.
|
|
76
116
|
// One offset per SURFACE: the rendered markdown and its source are different
|
|
77
117
|
// documents in the same container and share neither a line nor a height.
|
|
@@ -88,6 +128,34 @@ export function FileDocument({
|
|
|
88
128
|
<div className="relative flex-1 min-h-0 flex flex-col">
|
|
89
129
|
{find.open ? <FindWidget find={find} /> : null}
|
|
90
130
|
{paletteOpen ? <CommandPalette onRun={onRunCommand} onClose={onClosePalette} /> : null}
|
|
131
|
+
{quickOpen && onOpenPath ? (
|
|
132
|
+
<QuickOpenModal
|
|
133
|
+
root={rootPath}
|
|
134
|
+
repo={repoPath}
|
|
135
|
+
onOpen={(path) => {
|
|
136
|
+
onCloseQuickOpen();
|
|
137
|
+
// Through `handleOpenFile`, so the tab gets the id scheme every other
|
|
138
|
+
// opener shares rather than one computed here.
|
|
139
|
+
onOpenPath(path);
|
|
140
|
+
}}
|
|
141
|
+
onClose={onCloseQuickOpen}
|
|
142
|
+
/>
|
|
143
|
+
) : null}
|
|
144
|
+
{goToLineOpen ? (
|
|
145
|
+
<GoToLineModal
|
|
146
|
+
lineCount={editor.content ? editor.content.split('\n').length : 1}
|
|
147
|
+
onGo={(line) => {
|
|
148
|
+
setGoToLineOpen(false);
|
|
149
|
+
// The handle already owns "put the caret here and show it", which is why
|
|
150
|
+
// this needs no CodeMirror import: the find bar, the outline jump and the
|
|
151
|
+
// search reveal all go through the same two calls.
|
|
152
|
+
const offset = lineStartOffset(editor.content, line - 1);
|
|
153
|
+
surfaceRef.current?.select(offset, offset, true);
|
|
154
|
+
surfaceRef.current?.revealOffset(offset);
|
|
155
|
+
}}
|
|
156
|
+
onClose={() => setGoToLineOpen(false)}
|
|
157
|
+
/>
|
|
158
|
+
) : null}
|
|
91
159
|
{isMd && isPreview ? (
|
|
92
160
|
<div
|
|
93
161
|
ref={scroll.ref}
|
|
@@ -125,6 +193,7 @@ export function FileDocument({
|
|
|
125
193
|
currentMark={find.currentIndex}
|
|
126
194
|
onCommand={onRunCommand}
|
|
127
195
|
onScroller={setCodeScroller}
|
|
196
|
+
onCaret={setCaret}
|
|
128
197
|
scrollTestId="editor-scroller"
|
|
129
198
|
// The editor theme paints its own surface, so the app's `bg-paper`
|
|
130
199
|
// must not sit under it: an explicit theme's background is opaque and
|
|
@@ -132,6 +201,8 @@ export function FileDocument({
|
|
|
132
201
|
className="flex-1 min-h-0 text-ink select-text"
|
|
133
202
|
themeVars={editorTheme.vars}
|
|
134
203
|
themes={editorTheme.themes}
|
|
204
|
+
indentUnitText={indentUnitFor(editorIndent)}
|
|
205
|
+
typing={editorTyping}
|
|
135
206
|
padding={16}
|
|
136
207
|
style={{
|
|
137
208
|
fontFamily: editorFontFamily,
|
|
@@ -140,6 +211,23 @@ export function FileDocument({
|
|
|
140
211
|
}}
|
|
141
212
|
/>
|
|
142
213
|
)}
|
|
214
|
+
|
|
215
|
+
{/* Where the caret is, how the file is indented, and how it ends. The phone's
|
|
216
|
+
strip has printed the first of those since the editor was rebuilt; the
|
|
217
|
+
desktop pane had nothing, so the line number had to be counted. */}
|
|
218
|
+
{!isMd || !isPreview ? (
|
|
219
|
+
<EditorStatusBar
|
|
220
|
+
caret={caret}
|
|
221
|
+
eol={editor.eol}
|
|
222
|
+
onSetEol={editor.setEol}
|
|
223
|
+
indentWidth={editorIndent.width}
|
|
224
|
+
insertSpaces={editorIndent.insertSpaces}
|
|
225
|
+
language={editor.language}
|
|
226
|
+
byteViewer={editor.isBinaryViewer}
|
|
227
|
+
viewerKind={viewerKind}
|
|
228
|
+
lineCount={editor.content ? editor.content.split('\n').length : 0}
|
|
229
|
+
/>
|
|
230
|
+
) : null}
|
|
143
231
|
</div>
|
|
144
232
|
);
|
|
145
233
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RefObject } from 'preact';
|
|
2
2
|
import { AlertTriangle, FileX, Loader2 } from 'lucide-preact';
|
|
3
|
+
import { ConflictStrip } from '@/client/components/workspace/editor/ConflictStrip';
|
|
3
4
|
import { EditorToolbar } from '@/client/components/workspace/editor/Toolbar';
|
|
4
5
|
import { FileDocument } from '@/client/components/workspace/editor/FileDocument';
|
|
5
6
|
import { PluginFileViewBody, type ResolvedPluginFileView } from '@/client/components/workspace/editor/plugin-file-view';
|
|
@@ -32,6 +33,16 @@ interface FilePaneProps {
|
|
|
32
33
|
setZoomLevel: (update: (current: number) => number) => void;
|
|
33
34
|
paletteOpen: boolean;
|
|
34
35
|
setPaletteOpen: (open: boolean) => void;
|
|
36
|
+
/** Bumped when the user asks for "go to line"; this pane owns the dialog. */
|
|
37
|
+
goToLineRequest: number;
|
|
38
|
+
/** Open the Save As dialog. */
|
|
39
|
+
onSaveAs: () => void;
|
|
40
|
+
/** The file picker is open. */
|
|
41
|
+
quickOpen: boolean;
|
|
42
|
+
onCloseQuickOpen: () => void;
|
|
43
|
+
onOpenPath?: (path: string) => void;
|
|
44
|
+
rootPath?: string | null;
|
|
45
|
+
repoPath?: string | null;
|
|
35
46
|
runCommand: (command: EditorCommand) => void;
|
|
36
47
|
editorFontFamily: string;
|
|
37
48
|
editorTheme: EditorThemeState;
|
|
@@ -73,6 +84,13 @@ export function FilePane({
|
|
|
73
84
|
setZoomLevel,
|
|
74
85
|
paletteOpen,
|
|
75
86
|
setPaletteOpen,
|
|
87
|
+
goToLineRequest,
|
|
88
|
+
onSaveAs,
|
|
89
|
+
quickOpen,
|
|
90
|
+
onCloseQuickOpen,
|
|
91
|
+
onOpenPath,
|
|
92
|
+
rootPath = null,
|
|
93
|
+
repoPath = null,
|
|
76
94
|
runCommand,
|
|
77
95
|
editorFontFamily,
|
|
78
96
|
editorTheme,
|
|
@@ -109,6 +127,11 @@ export function FilePane({
|
|
|
109
127
|
onZoomOut={() => setZoomLevel((z) => Math.max(EDITOR_MIN_FONT_SIZE, z - 1))}
|
|
110
128
|
onCopy={editor.copy}
|
|
111
129
|
onDownload={editor.download}
|
|
130
|
+
onRevert={editor.revertToDisk}
|
|
131
|
+
onSaveAs={onSaveAs}
|
|
132
|
+
// Only a buffer with edits has anything to throw away; a clean one would
|
|
133
|
+
// re-read the same bytes and blank the screen for a moment.
|
|
134
|
+
canRevert={editor.isDirty && !editor.loadError && !editor.unsupported}
|
|
112
135
|
onToggleMaximize={() => setIsMaximized(!isMaximized)}
|
|
113
136
|
/>
|
|
114
137
|
|
|
@@ -127,6 +150,19 @@ export function FilePane({
|
|
|
127
150
|
</div>
|
|
128
151
|
)}
|
|
129
152
|
|
|
153
|
+
{/* A save refused because the disk copy moved. Not a failure: the buffer is
|
|
154
|
+
intact, and the two answers are the only ones that exist. Above the
|
|
155
|
+
document rather than in a modal, because the user has to see what they
|
|
156
|
+
are choosing between. */}
|
|
157
|
+
{editor.conflict && (
|
|
158
|
+
<ConflictStrip
|
|
159
|
+
diskMtimeMs={editor.conflict.diskMtimeMs}
|
|
160
|
+
fileName={activeFile.name}
|
|
161
|
+
onReload={editor.resolveConflictByReload}
|
|
162
|
+
onKeepMine={editor.resolveConflictByKeepingMine}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
|
|
130
166
|
{/* A launched file's handle dies with the page, so after a reload the tab
|
|
131
167
|
can read and edit but cannot write. Saying so is the whole point: the
|
|
132
168
|
Save button is disabled, and a user who is not told why would read it
|
|
@@ -210,9 +246,16 @@ export function FilePane({
|
|
|
210
246
|
surfaceRef={surfaceRef}
|
|
211
247
|
paletteOpen={paletteOpen}
|
|
212
248
|
onClosePalette={() => setPaletteOpen(false)}
|
|
249
|
+
goToLineRequest={goToLineRequest}
|
|
250
|
+
quickOpen={quickOpen}
|
|
251
|
+
onCloseQuickOpen={onCloseQuickOpen}
|
|
252
|
+
onOpenPath={onOpenPath}
|
|
253
|
+
rootPath={rootPath}
|
|
254
|
+
repoPath={repoPath}
|
|
213
255
|
onRunCommand={runCommand}
|
|
214
256
|
wordWrap={wordWrap}
|
|
215
257
|
zoomLevel={zoomLevel}
|
|
258
|
+
setZoomLevel={setZoomLevel}
|
|
216
259
|
editorFontFamily={editorFontFamily}
|
|
217
260
|
editorTheme={editorTheme}
|
|
218
261
|
isPreview={isPreview}
|
|
@@ -33,12 +33,14 @@ const calls: string[] = [];
|
|
|
33
33
|
|
|
34
34
|
/** A find state whose every action records itself, so a click is provable. */
|
|
35
35
|
function findState(overrides: Partial<EditorFindState> = {}): EditorFindState {
|
|
36
|
-
|
|
36
|
+
// `Object.assign` rather than a spread: a spread of `Partial<T>` widens every
|
|
37
|
+
// required property to `| undefined`, which the contract rightly refuses.
|
|
38
|
+
return Object.assign<EditorFindState, Partial<EditorFindState>>({
|
|
37
39
|
open: true,
|
|
38
40
|
replaceOpen: false,
|
|
39
41
|
query: '',
|
|
40
42
|
replacement: '',
|
|
41
|
-
options: { matchCase: false, wholeWord: false, isRegex: false },
|
|
43
|
+
options: { matchCase: false, wholeWord: false, isRegex: false, inSelection: false },
|
|
42
44
|
matches: [],
|
|
43
45
|
truncated: false,
|
|
44
46
|
invalid: false,
|
|
@@ -56,8 +58,10 @@ function findState(overrides: Partial<EditorFindState> = {}): EditorFindState {
|
|
|
56
58
|
step: (direction) => calls.push(`step:${direction}`),
|
|
57
59
|
replaceCurrent: () => calls.push('replaceCurrent'),
|
|
58
60
|
replaceAll: () => calls.push('replaceAll'),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
selectionRange: null,
|
|
62
|
+
history: [],
|
|
63
|
+
useHistoryEntry: (value: string) => calls.push(`useHistoryEntry:${value}`),
|
|
64
|
+
}, overrides);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
async function mount(find: EditorFindState) {
|
|
@@ -178,7 +182,7 @@ describe('FindWidget', () => {
|
|
|
178
182
|
});
|
|
179
183
|
|
|
180
184
|
test('each toggle reports its own state and its own shortcut', async () => {
|
|
181
|
-
await mount(findState({ options: { matchCase: true, wholeWord: false, isRegex: true } }));
|
|
185
|
+
await mount(findState({ options: { matchCase: true, wholeWord: false, isRegex: true, inSelection: false } }));
|
|
182
186
|
|
|
183
187
|
const matchCase = byLabelPrefix('Match case');
|
|
184
188
|
const wholeWord = byLabelPrefix('Match whole word');
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
ChevronDown,
|
|
13
13
|
ChevronUp,
|
|
14
14
|
Regex,
|
|
15
|
+
TextSelect,
|
|
15
16
|
Replace,
|
|
16
17
|
ReplaceAll,
|
|
17
18
|
WholeWord,
|
|
@@ -146,6 +147,15 @@ export function FindWidget({ find }: FindWidgetProps) {
|
|
|
146
147
|
{optionButton('matchCase', 'Match case', 'toggleCaseSensitive', <CaseSensitive size={13} />)}
|
|
147
148
|
{optionButton('wholeWord', 'Match whole word', 'toggleWholeWord', <WholeWord size={13} />)}
|
|
148
149
|
{optionButton('isRegex', 'Use regular expression', 'toggleRegex', <Regex size={13} />)}
|
|
150
|
+
{/* In selection: armed from the selection at the moment it is switched on, so
|
|
151
|
+
the toggle means "the text I had selected", not "whatever is selected now". */}
|
|
152
|
+
<ToggleButton
|
|
153
|
+
active={find.options.inSelection}
|
|
154
|
+
title={find.options.inSelection ? 'Searching the selection only' : 'Search the selection only'}
|
|
155
|
+
onToggle={() => find.toggleOption('inSelection')}
|
|
156
|
+
>
|
|
157
|
+
<TextSelect size={13} />
|
|
158
|
+
</ToggleButton>
|
|
149
159
|
|
|
150
160
|
<span
|
|
151
161
|
className={`font-mono text-[10px] whitespace-nowrap min-w-[52px] text-right ${find.invalid ? 'text-error' : 'text-ink/50'}`}
|
|
@@ -185,6 +195,25 @@ export function FindWidget({ find }: FindWidgetProps) {
|
|
|
185
195
|
</button>
|
|
186
196
|
</div>
|
|
187
197
|
|
|
198
|
+
{/* Recent queries. Absent until there is one, so the bar does not grow a row
|
|
199
|
+
nobody has used. */}
|
|
200
|
+
{find.history.length > 0 && (
|
|
201
|
+
<div className="flex items-center gap-1 overflow-x-auto no-scrollbar">
|
|
202
|
+
<span className="text-[9px] uppercase tracking-wide text-ink/40 flex-shrink-0">Recent</span>
|
|
203
|
+
{find.history.slice(0, 6).map((entry) => (
|
|
204
|
+
<button
|
|
205
|
+
key={entry}
|
|
206
|
+
type="button"
|
|
207
|
+
onClick={() => find.useHistoryEntry(entry)}
|
|
208
|
+
title={`Find ${entry}`}
|
|
209
|
+
className="px-1.5 py-0.5 rounded border border-ink/15 font-mono text-[10px] text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer whitespace-nowrap flex-shrink-0"
|
|
210
|
+
>
|
|
211
|
+
{entry}
|
|
212
|
+
</button>
|
|
213
|
+
))}
|
|
214
|
+
</div>
|
|
215
|
+
)}
|
|
216
|
+
|
|
188
217
|
{find.replaceOpen && (
|
|
189
218
|
<div className="flex items-center gap-1">
|
|
190
219
|
<span className="w-[22px]" aria-hidden="true" />
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Go to line (⌘G).
|
|
8
|
+
*
|
|
9
|
+
* A one-field dialog rather than a prompt, because the panel already has the modal
|
|
10
|
+
* shell and because the two things that make this feature usable are both UI: the
|
|
11
|
+
* field must be pre-selected (the user is typing a number, not editing text), and a
|
|
12
|
+
* number past the end must be CLAMPED rather than refused — "go to the end" is what
|
|
13
|
+
* a too-large number means.
|
|
14
|
+
*
|
|
15
|
+
* ## Why it goes through the surface handle
|
|
16
|
+
*
|
|
17
|
+
* `CodeSurfaceHandle` already has `select(offset, offset)` and `revealOffset`, which
|
|
18
|
+
* is exactly "put the caret on this line and scroll it into view". Importing
|
|
19
|
+
* CodeMirror here would be a second way into the same view, and the handle is the
|
|
20
|
+
* contract that kept the find bar, the outline jump and the search reveal working
|
|
21
|
+
* without knowing CM6 exists.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
25
|
+
import type { TargetedKeyboardEvent } from 'preact';
|
|
26
|
+
import { CornerDownLeft } from 'lucide-preact';
|
|
27
|
+
|
|
28
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
29
|
+
|
|
30
|
+
interface GoToLineModalProps {
|
|
31
|
+
/** Total lines in the document, so a request can be clamped and named. */
|
|
32
|
+
lineCount: number;
|
|
33
|
+
onGo: (line: number) => void;
|
|
34
|
+
onClose: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The line a typed value resolves to.
|
|
39
|
+
*
|
|
40
|
+
* `null` for anything that is not a number, so the field can stay open with its
|
|
41
|
+
* value untouched instead of jumping to line 1 on a typo.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveLineRequest(raw: string, lineCount: number): number | null {
|
|
44
|
+
const trimmed = raw.trim();
|
|
45
|
+
if (!/^\d+$/.test(trimmed)) return null;
|
|
46
|
+
const requested = Number(trimmed);
|
|
47
|
+
if (requested < 1) return null;
|
|
48
|
+
// Clamped, not refused: a number past the end means "the end", which is the only
|
|
49
|
+
// reading that does not waste the user's keystroke.
|
|
50
|
+
return Math.min(requested, Math.max(lineCount, 1));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function GoToLineModal({ lineCount, onGo, onClose }: GoToLineModalProps) {
|
|
54
|
+
const [value, setValue] = useState('');
|
|
55
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
// Focus AND select: the field starts empty, and a re-open after a jump should
|
|
59
|
+
// replace the previous number rather than append to it.
|
|
60
|
+
inputRef.current?.focus();
|
|
61
|
+
inputRef.current?.select();
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const submit = () => {
|
|
65
|
+
const line = resolveLineRequest(value, lineCount);
|
|
66
|
+
if (line === null) return;
|
|
67
|
+
onGo(line);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onKeyDown = (event: TargetedKeyboardEvent<HTMLInputElement>) => {
|
|
71
|
+
if (event.key === 'Enter') {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
submit();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (event.key === 'Escape') {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
onClose();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const resolved = resolveLineRequest(value, lineCount);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Modal
|
|
86
|
+
onClose={onClose}
|
|
87
|
+
maxWidthClass="max-w-xs"
|
|
88
|
+
header={<span className="text-sm font-semibold text-ink">Go to line</span>}
|
|
89
|
+
>
|
|
90
|
+
<div className="px-4 py-3 space-y-2">
|
|
91
|
+
<div className="flex items-center gap-2">
|
|
92
|
+
<input
|
|
93
|
+
ref={inputRef}
|
|
94
|
+
value={value}
|
|
95
|
+
onInput={(event) => setValue((event.target as HTMLInputElement).value)}
|
|
96
|
+
onKeyDown={onKeyDown}
|
|
97
|
+
inputMode="numeric"
|
|
98
|
+
placeholder="1"
|
|
99
|
+
aria-label="Line number"
|
|
100
|
+
className="flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"
|
|
101
|
+
/>
|
|
102
|
+
<span className="text-[10px] font-mono text-ink/40">/ {lineCount}</span>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
onClick={submit}
|
|
106
|
+
disabled={resolved === null}
|
|
107
|
+
className="flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer"
|
|
108
|
+
>
|
|
109
|
+
<CornerDownLeft size={12} />
|
|
110
|
+
Go
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
{/* The resolved line, so a clamped request says so before the jump. */}
|
|
114
|
+
{value && resolved !== null && String(resolved) !== value.trim() ? (
|
|
115
|
+
<div className="text-[10px] text-ink/50 font-mono">line {resolved} (the last line)</div>
|
|
116
|
+
) : null}
|
|
117
|
+
{value && resolved === null ? (
|
|
118
|
+
<div className="text-[10px] text-error font-mono">Enter a line number</div>
|
|
119
|
+
) : null}
|
|
120
|
+
</div>
|
|
121
|
+
</Modal>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The strips that stand between the toolbar and the document.
|
|
8
|
+
*
|
|
9
|
+
* Three of them, and each is a different fact about the same file:
|
|
10
|
+
*
|
|
11
|
+
* - **external change** — the disk moved while the buffer has edits, and nothing has
|
|
12
|
+
* been written yet;
|
|
13
|
+
* - **conflict** — a save was REFUSED because the disk moved, so the buffer is ahead
|
|
14
|
+
* and the server declined to overwrite;
|
|
15
|
+
* - **deleted** — the file is gone from disk, which the tab strip also says but in a
|
|
16
|
+
* small target in a crowded row.
|
|
17
|
+
*
|
|
18
|
+
* They sit above the document rather than in a modal because the user has to see the
|
|
19
|
+
* file they are choosing about, and they are one component rather than three call
|
|
20
|
+
* sites because two of them must never render together: a conflict is the LATER
|
|
21
|
+
* state of an external change, so showing both would ask the same question twice.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { ExternalChangeStrip } from '@/client/components/workspace/editor/ExternalChangeStrip';
|
|
25
|
+
import { ConflictStrip } from '@/client/components/workspace/editor/ConflictStrip';
|
|
26
|
+
import type { DiskChange } from '@/client/hooks/editor/use-external-change';
|
|
27
|
+
import type { WriteConflict } from '@/client/hooks/editor/use-write-conflict';
|
|
28
|
+
import type { OpenedFile } from '@/shared/types/fs';
|
|
29
|
+
|
|
30
|
+
interface EditorNoticesProps {
|
|
31
|
+
activeFile: OpenedFile | undefined;
|
|
32
|
+
/** The disk moved under a dirty buffer, or null. */
|
|
33
|
+
externalChange: DiskChange | null;
|
|
34
|
+
/** A save was refused because the disk moved, or null. */
|
|
35
|
+
conflict: WriteConflict | null;
|
|
36
|
+
/** Take the disk copy and drop the buffer's edits. */
|
|
37
|
+
onReload: () => void;
|
|
38
|
+
/** Adopt the disk's mtime and keep editing. */
|
|
39
|
+
onKeepMine: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function EditorNotices({
|
|
43
|
+
activeFile,
|
|
44
|
+
externalChange,
|
|
45
|
+
conflict,
|
|
46
|
+
onReload,
|
|
47
|
+
onKeepMine,
|
|
48
|
+
}: EditorNoticesProps) {
|
|
49
|
+
if (!activeFile) return null;
|
|
50
|
+
|
|
51
|
+
// The conflict wins: it is the later state of the same story, and it is the one
|
|
52
|
+
// whose answer writes bytes. Offering both would be two controls for one choice.
|
|
53
|
+
if (conflict) {
|
|
54
|
+
return (
|
|
55
|
+
<ConflictStrip
|
|
56
|
+
diskMtimeMs={conflict.diskMtimeMs}
|
|
57
|
+
fileName={activeFile.name}
|
|
58
|
+
onReload={onReload}
|
|
59
|
+
onKeepMine={onKeepMine}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (externalChange) {
|
|
65
|
+
return (
|
|
66
|
+
<ExternalChangeStrip fileName={activeFile.name} onReload={onReload} onKeepMine={onKeepMine} />
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One pane of the editor column: the strip, the notices, the body, the Save As dialog and
|
|
8
|
+
* the two confirmations.
|
|
9
|
+
*
|
|
10
|
+
* Extracted so the SPLIT can render the same thing twice. A second hand-written pane would
|
|
11
|
+
* be a second list of what a pane contains, and the two would drift the moment one gained a
|
|
12
|
+
* notice — which is the class of bug the split must not introduce.
|
|
13
|
+
*
|
|
14
|
+
* It takes DATA (the file, the buffer, the conflict) and builds its own slots, so the panel
|
|
15
|
+
* only decides which pane it is drawing. That is also what keeps `index.tsx` under the
|
|
16
|
+
* repository's line ceiling as the column grew a split.
|
|
17
|
+
*
|
|
18
|
+
* ## A split pane draws no strip
|
|
19
|
+
*
|
|
20
|
+
* The tab order and the active tab belong to the LEFT pane, so a second strip would be a
|
|
21
|
+
* second owner of both.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { ComponentChildren } from 'preact';
|
|
25
|
+
|
|
26
|
+
import { EditorNotices } from '@/client/components/workspace/editor/Notices';
|
|
27
|
+
import { SaveAsModal } from '@/client/components/workspace/editor/SaveAsModal';
|
|
28
|
+
import { EditorDialogs } from '@/client/components/workspace/editor/Dialogs';
|
|
29
|
+
import type { DiskChange } from '@/client/hooks/editor/use-external-change';
|
|
30
|
+
import type { CloseGuard } from '@/client/hooks/editor/use-close-guard';
|
|
31
|
+
import type { UseFileEditorResult } from '@/client/hooks/editor/file-editor-types';
|
|
32
|
+
import type { WriteConflict } from '@/client/hooks/editor/use-write-conflict';
|
|
33
|
+
import type { OpenedFile } from '@/shared/types/fs';
|
|
34
|
+
|
|
35
|
+
interface EditorPaneProps {
|
|
36
|
+
className?: string;
|
|
37
|
+
isMaximized: boolean;
|
|
38
|
+
onKeyDownCapture: (event: never) => void;
|
|
39
|
+
asSplitPane: boolean;
|
|
40
|
+
/** The tab strip. Dropped in a split pane. */
|
|
41
|
+
tabs: ComponentChildren;
|
|
42
|
+
/** The active file and the buffer it is drawn from. */
|
|
43
|
+
activeFile: OpenedFile | undefined;
|
|
44
|
+
editor: UseFileEditorResult;
|
|
45
|
+
externalChange: DiskChange | null;
|
|
46
|
+
conflict: WriteConflict | null;
|
|
47
|
+
onReload: () => void;
|
|
48
|
+
onKeepMine: () => void;
|
|
49
|
+
/** The document area (toolbar + surface), already assembled. */
|
|
50
|
+
body: ComponentChildren;
|
|
51
|
+
/** Save As is open, and the callback that closes it after a write. */
|
|
52
|
+
saveAsOpen: boolean;
|
|
53
|
+
onSaveAsClose: () => void;
|
|
54
|
+
onSavedAs: (path: string) => void;
|
|
55
|
+
closeGuard: CloseGuard;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function EditorPane({
|
|
59
|
+
className = '',
|
|
60
|
+
isMaximized,
|
|
61
|
+
onKeyDownCapture,
|
|
62
|
+
asSplitPane,
|
|
63
|
+
tabs,
|
|
64
|
+
activeFile,
|
|
65
|
+
editor,
|
|
66
|
+
externalChange,
|
|
67
|
+
conflict,
|
|
68
|
+
onReload,
|
|
69
|
+
onKeepMine,
|
|
70
|
+
body,
|
|
71
|
+
saveAsOpen,
|
|
72
|
+
onSaveAsClose,
|
|
73
|
+
onSavedAs,
|
|
74
|
+
closeGuard,
|
|
75
|
+
}: EditorPaneProps) {
|
|
76
|
+
const containerClass = isMaximized
|
|
77
|
+
? 'fixed inset-0 z-50 flex flex-col bg-canvas'
|
|
78
|
+
: `flex flex-col h-full bg-canvas ${className}`;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className={containerClass} onKeyDownCapture={onKeyDownCapture}>
|
|
82
|
+
{asSplitPane ? null : tabs}
|
|
83
|
+
|
|
84
|
+
<EditorNotices
|
|
85
|
+
activeFile={activeFile}
|
|
86
|
+
externalChange={externalChange}
|
|
87
|
+
conflict={conflict}
|
|
88
|
+
onReload={onReload}
|
|
89
|
+
onKeepMine={onKeepMine}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
{body}
|
|
93
|
+
|
|
94
|
+
{/* Save As needs the BUFFER, so it is built here from the editor state rather than
|
|
95
|
+
handed in as a slot. */}
|
|
96
|
+
{saveAsOpen && activeFile ? (
|
|
97
|
+
<SaveAsModal
|
|
98
|
+
fileName={activeFile.name}
|
|
99
|
+
filePath={activeFile.path}
|
|
100
|
+
content={editor.content}
|
|
101
|
+
eol={editor.eol}
|
|
102
|
+
root={activeFile.root}
|
|
103
|
+
repo={activeFile.repo}
|
|
104
|
+
onSaved={({ path }) => onSavedAs(path)}
|
|
105
|
+
onClose={onSaveAsClose}
|
|
106
|
+
/>
|
|
107
|
+
) : null}
|
|
108
|
+
|
|
109
|
+
<EditorDialogs
|
|
110
|
+
closeGuard={closeGuard}
|
|
111
|
+
activeFile={activeFile}
|
|
112
|
+
saveMissingConfirm={editor.saveMissingConfirm}
|
|
113
|
+
onCancelSaveMissing={editor.cancelSaveMissing}
|
|
114
|
+
onConfirmSaveMissing={editor.confirmSaveMissing}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The editor column taken over by a plugin.
|
|
8
|
+
*
|
|
9
|
+
* There is no tab strip in this mode and no file: the plugin owns the whole surface, the
|
|
10
|
+
* way a right-panel view does, and the layout's own toggle is what gives the column back.
|
|
11
|
+
* `PluginIdProvider` is what lets the plugin's own components resolve their registration.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { ComponentType } from 'preact/compat';
|
|
15
|
+
import { PluginIdProvider } from '@kabmo-labs/kabmo-ui';
|
|
16
|
+
|
|
17
|
+
interface PluginColumnProps {
|
|
18
|
+
pluginId: string;
|
|
19
|
+
Component: ComponentType<{ sessionId: string | null; workspacePath: string | null }>;
|
|
20
|
+
sessionId: string | null;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function PluginColumn({ pluginId, Component, sessionId, className = '' }: PluginColumnProps) {
|
|
25
|
+
return (
|
|
26
|
+
<div className={`flex flex-col h-full bg-canvas ${className}`}>
|
|
27
|
+
<PluginIdProvider pluginId={pluginId}>
|
|
28
|
+
<Component sessionId={sessionId} workspacePath={null} />
|
|
29
|
+
</PluginIdProvider>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|