@velo-sci/notebook-react 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +3022 -0
- package/dist/index.d.cts +312 -0
- package/dist/index.d.ts +312 -0
- package/dist/index.js +2954 -0
- package/package.json +36 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { EditorEngine, Cell as Cell$1, Notebook, EventPayload, SciNotebookPlugin, CellType, CellOutput } from '@velo-sci/notebook-core';
|
|
4
|
+
import { RenderPipeline } from '@velo-sci/notebook-renderer';
|
|
5
|
+
|
|
6
|
+
declare const NotebookContext: React.Context<EditorEngine | null>;
|
|
7
|
+
declare function useSciNotebook(): EditorEngine;
|
|
8
|
+
declare function useNotebook(): Readonly<Notebook>;
|
|
9
|
+
declare function useCell(cellId: string): Readonly<Cell$1> | undefined;
|
|
10
|
+
declare function useFocusedCell(): string | null;
|
|
11
|
+
declare function useNotebookEvent(type: string, handler: (payload: EventPayload) => void): void;
|
|
12
|
+
|
|
13
|
+
interface SciNotebookProps {
|
|
14
|
+
/** Pre-built notebook object */
|
|
15
|
+
notebook?: Notebook;
|
|
16
|
+
/** Pre-built engine (takes priority over notebook) */
|
|
17
|
+
engine?: EditorEngine;
|
|
18
|
+
/** Plugins to register */
|
|
19
|
+
plugins?: SciNotebookPlugin[];
|
|
20
|
+
/** Zero-config: just pass markdown content */
|
|
21
|
+
initialContent?: string;
|
|
22
|
+
/** Theme */
|
|
23
|
+
theme?: "light" | "dark" | string;
|
|
24
|
+
/** Callback when notebook changes */
|
|
25
|
+
onChange?: (notebook: Notebook) => void;
|
|
26
|
+
/** Callback when a cell is focused */
|
|
27
|
+
onCellFocus?: (cellId: string | null) => void;
|
|
28
|
+
/** Read-only mode */
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
/** Show/hide the top toolbar */
|
|
31
|
+
showToolbar?: boolean;
|
|
32
|
+
/** CSS class */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** Inline styles */
|
|
35
|
+
style?: React__default.CSSProperties;
|
|
36
|
+
/** Imperative engine access */
|
|
37
|
+
engineRef?: React__default.MutableRefObject<EditorEngine | null>;
|
|
38
|
+
/** Show TOC sidebar */
|
|
39
|
+
showTOC?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const SciNotebook: React__default.FC<SciNotebookProps>;
|
|
42
|
+
|
|
43
|
+
interface CellProps {
|
|
44
|
+
cellId: string;
|
|
45
|
+
pipeline: RenderPipeline;
|
|
46
|
+
index: number;
|
|
47
|
+
totalCells: number;
|
|
48
|
+
}
|
|
49
|
+
declare const Cell: React__default.FC<CellProps>;
|
|
50
|
+
|
|
51
|
+
interface InsertHandleProps {
|
|
52
|
+
index: number;
|
|
53
|
+
}
|
|
54
|
+
declare const InsertHandle: React__default.FC<InsertHandleProps>;
|
|
55
|
+
|
|
56
|
+
interface FloatingToolbarProps {
|
|
57
|
+
cellId: string;
|
|
58
|
+
textareaRef: React__default.RefObject<HTMLTextAreaElement | null>;
|
|
59
|
+
}
|
|
60
|
+
declare const FloatingToolbar: React__default.FC<FloatingToolbarProps>;
|
|
61
|
+
|
|
62
|
+
interface MathEditorProps {
|
|
63
|
+
cellId: string;
|
|
64
|
+
source: string;
|
|
65
|
+
onExit: () => void;
|
|
66
|
+
}
|
|
67
|
+
declare const MathEditor: React__default.FC<MathEditorProps>;
|
|
68
|
+
|
|
69
|
+
interface ImageCellProps {
|
|
70
|
+
cellId: string;
|
|
71
|
+
source: string;
|
|
72
|
+
metadata: Record<string, unknown>;
|
|
73
|
+
onExit: () => void;
|
|
74
|
+
}
|
|
75
|
+
declare const ImageCell: React__default.FC<ImageCellProps>;
|
|
76
|
+
declare function renderImagePreview(source: string, metadata: Record<string, unknown>): string;
|
|
77
|
+
|
|
78
|
+
interface EmbedCellProps {
|
|
79
|
+
cellId: string;
|
|
80
|
+
source: string;
|
|
81
|
+
metadata: Record<string, unknown>;
|
|
82
|
+
onExit: () => void;
|
|
83
|
+
}
|
|
84
|
+
declare const EmbedCell: React__default.FC<EmbedCellProps>;
|
|
85
|
+
declare function renderEmbedPreview(source: string, metadata: Record<string, unknown>): string;
|
|
86
|
+
|
|
87
|
+
interface SlashCommandItem {
|
|
88
|
+
type: CellType;
|
|
89
|
+
label: string;
|
|
90
|
+
description: string;
|
|
91
|
+
icon: string;
|
|
92
|
+
keywords: string[];
|
|
93
|
+
}
|
|
94
|
+
declare const DEFAULT_COMMANDS: SlashCommandItem[];
|
|
95
|
+
interface SlashCommandProps {
|
|
96
|
+
/** Position relative to the textarea */
|
|
97
|
+
position: {
|
|
98
|
+
top: number;
|
|
99
|
+
left: number;
|
|
100
|
+
};
|
|
101
|
+
/** Filter query (text after /) */
|
|
102
|
+
query: string;
|
|
103
|
+
/** Called when a command is selected */
|
|
104
|
+
onSelect: (type: CellType) => void;
|
|
105
|
+
/** Called when the menu should close */
|
|
106
|
+
onClose: () => void;
|
|
107
|
+
/** Custom commands (optional, extends defaults) */
|
|
108
|
+
extraCommands?: SlashCommandItem[];
|
|
109
|
+
}
|
|
110
|
+
declare const SlashCommand: React__default.FC<SlashCommandProps>;
|
|
111
|
+
|
|
112
|
+
interface TableCellProps {
|
|
113
|
+
cellId: string;
|
|
114
|
+
source: string;
|
|
115
|
+
metadata: Record<string, unknown>;
|
|
116
|
+
onExit: () => void;
|
|
117
|
+
}
|
|
118
|
+
declare const TableCell: React__default.FC<TableCellProps>;
|
|
119
|
+
declare function renderTablePreview(source: string): string;
|
|
120
|
+
|
|
121
|
+
interface TOCItem {
|
|
122
|
+
cellId: string;
|
|
123
|
+
level: number;
|
|
124
|
+
text: string;
|
|
125
|
+
}
|
|
126
|
+
declare const TOCSidebar: React__default.FC<{
|
|
127
|
+
focusedCellId?: string | null;
|
|
128
|
+
}>;
|
|
129
|
+
|
|
130
|
+
interface FindMatch {
|
|
131
|
+
cellId: string;
|
|
132
|
+
index: number;
|
|
133
|
+
length: number;
|
|
134
|
+
}
|
|
135
|
+
interface FindReplaceProps {
|
|
136
|
+
onClose: () => void;
|
|
137
|
+
}
|
|
138
|
+
declare const FindReplace: React__default.FC<FindReplaceProps>;
|
|
139
|
+
|
|
140
|
+
declare const LATEX_COMMANDS: Array<{
|
|
141
|
+
cmd: string;
|
|
142
|
+
desc: string;
|
|
143
|
+
category: string;
|
|
144
|
+
}>;
|
|
145
|
+
interface LatexAutocompleteProps {
|
|
146
|
+
query: string;
|
|
147
|
+
position: {
|
|
148
|
+
top: number;
|
|
149
|
+
left: number;
|
|
150
|
+
};
|
|
151
|
+
onSelect: (cmd: string) => void;
|
|
152
|
+
onClose: () => void;
|
|
153
|
+
}
|
|
154
|
+
declare const LatexAutocomplete: React__default.FC<LatexAutocompleteProps>;
|
|
155
|
+
|
|
156
|
+
interface CellOutputProps {
|
|
157
|
+
outputs: CellOutput[];
|
|
158
|
+
}
|
|
159
|
+
declare const CellOutputDisplay: React__default.FC<CellOutputProps>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Ghost Text overlay for AI inline completions.
|
|
163
|
+
*
|
|
164
|
+
* Renders a semi-transparent suggestion after the cursor position
|
|
165
|
+
* in a textarea. User presses Tab to accept, Escape to dismiss.
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
interface GhostTextProps {
|
|
169
|
+
text: string;
|
|
170
|
+
textareaRef: React__default.RefObject<HTMLTextAreaElement | null>;
|
|
171
|
+
onAccept: () => void;
|
|
172
|
+
onDismiss: () => void;
|
|
173
|
+
}
|
|
174
|
+
declare const GhostText: React__default.FC<GhostTextProps>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* AI Chat Sidebar for sci-notebook.
|
|
178
|
+
*
|
|
179
|
+
* Provides a conversational interface for interacting with AI providers.
|
|
180
|
+
* Supports sending messages, receiving streamed responses, and applying
|
|
181
|
+
* suggestions to cells.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
interface ChatMessage {
|
|
185
|
+
role: "user" | "assistant" | "system";
|
|
186
|
+
content: string;
|
|
187
|
+
timestamp: number;
|
|
188
|
+
cellRefs?: string[];
|
|
189
|
+
}
|
|
190
|
+
interface ChatSidebarProps {
|
|
191
|
+
/** Function to send a message to the AI provider */
|
|
192
|
+
onSend?: (message: string, history: ChatMessage[]) => Promise<string>;
|
|
193
|
+
/** Initial system prompt */
|
|
194
|
+
systemPrompt?: string;
|
|
195
|
+
/** Callback when user wants to apply a suggestion to a cell */
|
|
196
|
+
onApply?: (content: string, cellId?: string) => void;
|
|
197
|
+
/** Close handler */
|
|
198
|
+
onClose?: () => void;
|
|
199
|
+
}
|
|
200
|
+
declare const ChatSidebar: React__default.FC<ChatSidebarProps>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Image Resize Handles for sci-notebook.
|
|
204
|
+
*
|
|
205
|
+
* Wraps an image element with draggable resize handles (SE corner).
|
|
206
|
+
* Reports new width back to the parent via onResize callback.
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
interface ImageResizeProps {
|
|
210
|
+
src: string;
|
|
211
|
+
alt?: string;
|
|
212
|
+
initialWidth: string;
|
|
213
|
+
maxWidth?: string;
|
|
214
|
+
onResize: (newWidth: string) => void;
|
|
215
|
+
children?: React__default.ReactNode;
|
|
216
|
+
}
|
|
217
|
+
declare const ImageResize: React__default.FC<ImageResizeProps>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* VirtualRenderer for sci-notebook.
|
|
221
|
+
*
|
|
222
|
+
* Renders only the cells visible in the viewport for large notebooks (50+ cells).
|
|
223
|
+
* Uses IntersectionObserver for efficient visibility tracking and a sentinel
|
|
224
|
+
* element approach for smooth scrolling.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
interface VirtualRendererProps {
|
|
228
|
+
cells: ReadonlyArray<Cell$1>;
|
|
229
|
+
pipeline: RenderPipeline;
|
|
230
|
+
/** Estimated cell height in px (default: 120) */
|
|
231
|
+
estimatedHeight?: number;
|
|
232
|
+
/** Number of cells to render above/below viewport (default: 5) */
|
|
233
|
+
overscan?: number;
|
|
234
|
+
}
|
|
235
|
+
declare const VirtualRenderer: React__default.FC<VirtualRendererProps>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* MermaidCell — Renders Mermaid diagrams asynchronously.
|
|
239
|
+
*
|
|
240
|
+
* Uses globalThis.mermaid (consumer must import and expose mermaid).
|
|
241
|
+
* Handles async mermaid.render() from v10+.
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
interface MermaidPreviewProps {
|
|
245
|
+
source: string;
|
|
246
|
+
onClick?: () => void;
|
|
247
|
+
}
|
|
248
|
+
declare const MermaidPreview: React__default.FC<MermaidPreviewProps>;
|
|
249
|
+
/**
|
|
250
|
+
* Initialize mermaid globally. Call this once in your app entry point.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import mermaid from "mermaid";
|
|
255
|
+
* import { initMermaid } from "@velo-sci/notebook-react";
|
|
256
|
+
* initMermaid(mermaid);
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
declare function initMermaid(mermaidLib: any, config?: Record<string, unknown>): void;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* AI Rewrite Flow for sci-notebook.
|
|
263
|
+
*
|
|
264
|
+
* Flow: select text → prompt → preview diff → accept/reject
|
|
265
|
+
*
|
|
266
|
+
* This component renders as a floating panel near the selected text,
|
|
267
|
+
* allowing the user to provide a rewrite instruction and preview the result.
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
interface AIRewriteProps {
|
|
271
|
+
/** The currently selected text to rewrite */
|
|
272
|
+
selectedText: string;
|
|
273
|
+
/** Position to render the panel */
|
|
274
|
+
position: {
|
|
275
|
+
top: number;
|
|
276
|
+
left: number;
|
|
277
|
+
};
|
|
278
|
+
/** Called with the rewrite instruction; should return rewritten text */
|
|
279
|
+
onRewrite: (instruction: string, selectedText: string) => Promise<string>;
|
|
280
|
+
/** Called when user accepts the rewrite */
|
|
281
|
+
onAccept: (newText: string) => void;
|
|
282
|
+
/** Called when user rejects / closes */
|
|
283
|
+
onReject: () => void;
|
|
284
|
+
}
|
|
285
|
+
declare const AIRewrite: React__default.FC<AIRewriteProps>;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* AI Cell Generation UI for sci-notebook.
|
|
289
|
+
*
|
|
290
|
+
* Flow: prompt → generate → preview → insert cells
|
|
291
|
+
*
|
|
292
|
+
* Renders as a modal/inline panel where the user types a prompt,
|
|
293
|
+
* the AI generates one or more cells, and the user can accept or reject.
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
interface GeneratedCell {
|
|
297
|
+
type: CellType;
|
|
298
|
+
source: string;
|
|
299
|
+
}
|
|
300
|
+
interface AICellGenerateProps {
|
|
301
|
+
/** Called with the prompt; should return generated cells */
|
|
302
|
+
onGenerate: (prompt: string) => Promise<GeneratedCell[]>;
|
|
303
|
+
/** Called when user accepts the generated cells */
|
|
304
|
+
onAccept: (cells: GeneratedCell[]) => void;
|
|
305
|
+
/** Called when user closes without accepting */
|
|
306
|
+
onCancel: () => void;
|
|
307
|
+
/** Insert position index */
|
|
308
|
+
insertIndex: number;
|
|
309
|
+
}
|
|
310
|
+
declare const AICellGenerate: React__default.FC<AICellGenerateProps>;
|
|
311
|
+
|
|
312
|
+
export { AICellGenerate, type AICellGenerateProps, AIRewrite, type AIRewriteProps, Cell, CellOutputDisplay, type CellProps, type ChatMessage, ChatSidebar, type ChatSidebarProps, DEFAULT_COMMANDS, EmbedCell, type FindMatch, FindReplace, FloatingToolbar, type GeneratedCell, GhostText, ImageCell, ImageResize, InsertHandle, LATEX_COMMANDS, LatexAutocomplete, MathEditor, MermaidPreview, NotebookContext, SciNotebook, type SciNotebookProps, SlashCommand, type SlashCommandItem, type TOCItem, TOCSidebar, TableCell, VirtualRenderer, initMermaid, renderEmbedPreview, renderImagePreview, renderTablePreview, useCell, useFocusedCell, useNotebook, useNotebookEvent, useSciNotebook };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { EditorEngine, Cell as Cell$1, Notebook, EventPayload, SciNotebookPlugin, CellType, CellOutput } from '@velo-sci/notebook-core';
|
|
4
|
+
import { RenderPipeline } from '@velo-sci/notebook-renderer';
|
|
5
|
+
|
|
6
|
+
declare const NotebookContext: React.Context<EditorEngine | null>;
|
|
7
|
+
declare function useSciNotebook(): EditorEngine;
|
|
8
|
+
declare function useNotebook(): Readonly<Notebook>;
|
|
9
|
+
declare function useCell(cellId: string): Readonly<Cell$1> | undefined;
|
|
10
|
+
declare function useFocusedCell(): string | null;
|
|
11
|
+
declare function useNotebookEvent(type: string, handler: (payload: EventPayload) => void): void;
|
|
12
|
+
|
|
13
|
+
interface SciNotebookProps {
|
|
14
|
+
/** Pre-built notebook object */
|
|
15
|
+
notebook?: Notebook;
|
|
16
|
+
/** Pre-built engine (takes priority over notebook) */
|
|
17
|
+
engine?: EditorEngine;
|
|
18
|
+
/** Plugins to register */
|
|
19
|
+
plugins?: SciNotebookPlugin[];
|
|
20
|
+
/** Zero-config: just pass markdown content */
|
|
21
|
+
initialContent?: string;
|
|
22
|
+
/** Theme */
|
|
23
|
+
theme?: "light" | "dark" | string;
|
|
24
|
+
/** Callback when notebook changes */
|
|
25
|
+
onChange?: (notebook: Notebook) => void;
|
|
26
|
+
/** Callback when a cell is focused */
|
|
27
|
+
onCellFocus?: (cellId: string | null) => void;
|
|
28
|
+
/** Read-only mode */
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
/** Show/hide the top toolbar */
|
|
31
|
+
showToolbar?: boolean;
|
|
32
|
+
/** CSS class */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** Inline styles */
|
|
35
|
+
style?: React__default.CSSProperties;
|
|
36
|
+
/** Imperative engine access */
|
|
37
|
+
engineRef?: React__default.MutableRefObject<EditorEngine | null>;
|
|
38
|
+
/** Show TOC sidebar */
|
|
39
|
+
showTOC?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const SciNotebook: React__default.FC<SciNotebookProps>;
|
|
42
|
+
|
|
43
|
+
interface CellProps {
|
|
44
|
+
cellId: string;
|
|
45
|
+
pipeline: RenderPipeline;
|
|
46
|
+
index: number;
|
|
47
|
+
totalCells: number;
|
|
48
|
+
}
|
|
49
|
+
declare const Cell: React__default.FC<CellProps>;
|
|
50
|
+
|
|
51
|
+
interface InsertHandleProps {
|
|
52
|
+
index: number;
|
|
53
|
+
}
|
|
54
|
+
declare const InsertHandle: React__default.FC<InsertHandleProps>;
|
|
55
|
+
|
|
56
|
+
interface FloatingToolbarProps {
|
|
57
|
+
cellId: string;
|
|
58
|
+
textareaRef: React__default.RefObject<HTMLTextAreaElement | null>;
|
|
59
|
+
}
|
|
60
|
+
declare const FloatingToolbar: React__default.FC<FloatingToolbarProps>;
|
|
61
|
+
|
|
62
|
+
interface MathEditorProps {
|
|
63
|
+
cellId: string;
|
|
64
|
+
source: string;
|
|
65
|
+
onExit: () => void;
|
|
66
|
+
}
|
|
67
|
+
declare const MathEditor: React__default.FC<MathEditorProps>;
|
|
68
|
+
|
|
69
|
+
interface ImageCellProps {
|
|
70
|
+
cellId: string;
|
|
71
|
+
source: string;
|
|
72
|
+
metadata: Record<string, unknown>;
|
|
73
|
+
onExit: () => void;
|
|
74
|
+
}
|
|
75
|
+
declare const ImageCell: React__default.FC<ImageCellProps>;
|
|
76
|
+
declare function renderImagePreview(source: string, metadata: Record<string, unknown>): string;
|
|
77
|
+
|
|
78
|
+
interface EmbedCellProps {
|
|
79
|
+
cellId: string;
|
|
80
|
+
source: string;
|
|
81
|
+
metadata: Record<string, unknown>;
|
|
82
|
+
onExit: () => void;
|
|
83
|
+
}
|
|
84
|
+
declare const EmbedCell: React__default.FC<EmbedCellProps>;
|
|
85
|
+
declare function renderEmbedPreview(source: string, metadata: Record<string, unknown>): string;
|
|
86
|
+
|
|
87
|
+
interface SlashCommandItem {
|
|
88
|
+
type: CellType;
|
|
89
|
+
label: string;
|
|
90
|
+
description: string;
|
|
91
|
+
icon: string;
|
|
92
|
+
keywords: string[];
|
|
93
|
+
}
|
|
94
|
+
declare const DEFAULT_COMMANDS: SlashCommandItem[];
|
|
95
|
+
interface SlashCommandProps {
|
|
96
|
+
/** Position relative to the textarea */
|
|
97
|
+
position: {
|
|
98
|
+
top: number;
|
|
99
|
+
left: number;
|
|
100
|
+
};
|
|
101
|
+
/** Filter query (text after /) */
|
|
102
|
+
query: string;
|
|
103
|
+
/** Called when a command is selected */
|
|
104
|
+
onSelect: (type: CellType) => void;
|
|
105
|
+
/** Called when the menu should close */
|
|
106
|
+
onClose: () => void;
|
|
107
|
+
/** Custom commands (optional, extends defaults) */
|
|
108
|
+
extraCommands?: SlashCommandItem[];
|
|
109
|
+
}
|
|
110
|
+
declare const SlashCommand: React__default.FC<SlashCommandProps>;
|
|
111
|
+
|
|
112
|
+
interface TableCellProps {
|
|
113
|
+
cellId: string;
|
|
114
|
+
source: string;
|
|
115
|
+
metadata: Record<string, unknown>;
|
|
116
|
+
onExit: () => void;
|
|
117
|
+
}
|
|
118
|
+
declare const TableCell: React__default.FC<TableCellProps>;
|
|
119
|
+
declare function renderTablePreview(source: string): string;
|
|
120
|
+
|
|
121
|
+
interface TOCItem {
|
|
122
|
+
cellId: string;
|
|
123
|
+
level: number;
|
|
124
|
+
text: string;
|
|
125
|
+
}
|
|
126
|
+
declare const TOCSidebar: React__default.FC<{
|
|
127
|
+
focusedCellId?: string | null;
|
|
128
|
+
}>;
|
|
129
|
+
|
|
130
|
+
interface FindMatch {
|
|
131
|
+
cellId: string;
|
|
132
|
+
index: number;
|
|
133
|
+
length: number;
|
|
134
|
+
}
|
|
135
|
+
interface FindReplaceProps {
|
|
136
|
+
onClose: () => void;
|
|
137
|
+
}
|
|
138
|
+
declare const FindReplace: React__default.FC<FindReplaceProps>;
|
|
139
|
+
|
|
140
|
+
declare const LATEX_COMMANDS: Array<{
|
|
141
|
+
cmd: string;
|
|
142
|
+
desc: string;
|
|
143
|
+
category: string;
|
|
144
|
+
}>;
|
|
145
|
+
interface LatexAutocompleteProps {
|
|
146
|
+
query: string;
|
|
147
|
+
position: {
|
|
148
|
+
top: number;
|
|
149
|
+
left: number;
|
|
150
|
+
};
|
|
151
|
+
onSelect: (cmd: string) => void;
|
|
152
|
+
onClose: () => void;
|
|
153
|
+
}
|
|
154
|
+
declare const LatexAutocomplete: React__default.FC<LatexAutocompleteProps>;
|
|
155
|
+
|
|
156
|
+
interface CellOutputProps {
|
|
157
|
+
outputs: CellOutput[];
|
|
158
|
+
}
|
|
159
|
+
declare const CellOutputDisplay: React__default.FC<CellOutputProps>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Ghost Text overlay for AI inline completions.
|
|
163
|
+
*
|
|
164
|
+
* Renders a semi-transparent suggestion after the cursor position
|
|
165
|
+
* in a textarea. User presses Tab to accept, Escape to dismiss.
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
interface GhostTextProps {
|
|
169
|
+
text: string;
|
|
170
|
+
textareaRef: React__default.RefObject<HTMLTextAreaElement | null>;
|
|
171
|
+
onAccept: () => void;
|
|
172
|
+
onDismiss: () => void;
|
|
173
|
+
}
|
|
174
|
+
declare const GhostText: React__default.FC<GhostTextProps>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* AI Chat Sidebar for sci-notebook.
|
|
178
|
+
*
|
|
179
|
+
* Provides a conversational interface for interacting with AI providers.
|
|
180
|
+
* Supports sending messages, receiving streamed responses, and applying
|
|
181
|
+
* suggestions to cells.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
interface ChatMessage {
|
|
185
|
+
role: "user" | "assistant" | "system";
|
|
186
|
+
content: string;
|
|
187
|
+
timestamp: number;
|
|
188
|
+
cellRefs?: string[];
|
|
189
|
+
}
|
|
190
|
+
interface ChatSidebarProps {
|
|
191
|
+
/** Function to send a message to the AI provider */
|
|
192
|
+
onSend?: (message: string, history: ChatMessage[]) => Promise<string>;
|
|
193
|
+
/** Initial system prompt */
|
|
194
|
+
systemPrompt?: string;
|
|
195
|
+
/** Callback when user wants to apply a suggestion to a cell */
|
|
196
|
+
onApply?: (content: string, cellId?: string) => void;
|
|
197
|
+
/** Close handler */
|
|
198
|
+
onClose?: () => void;
|
|
199
|
+
}
|
|
200
|
+
declare const ChatSidebar: React__default.FC<ChatSidebarProps>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Image Resize Handles for sci-notebook.
|
|
204
|
+
*
|
|
205
|
+
* Wraps an image element with draggable resize handles (SE corner).
|
|
206
|
+
* Reports new width back to the parent via onResize callback.
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
interface ImageResizeProps {
|
|
210
|
+
src: string;
|
|
211
|
+
alt?: string;
|
|
212
|
+
initialWidth: string;
|
|
213
|
+
maxWidth?: string;
|
|
214
|
+
onResize: (newWidth: string) => void;
|
|
215
|
+
children?: React__default.ReactNode;
|
|
216
|
+
}
|
|
217
|
+
declare const ImageResize: React__default.FC<ImageResizeProps>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* VirtualRenderer for sci-notebook.
|
|
221
|
+
*
|
|
222
|
+
* Renders only the cells visible in the viewport for large notebooks (50+ cells).
|
|
223
|
+
* Uses IntersectionObserver for efficient visibility tracking and a sentinel
|
|
224
|
+
* element approach for smooth scrolling.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
interface VirtualRendererProps {
|
|
228
|
+
cells: ReadonlyArray<Cell$1>;
|
|
229
|
+
pipeline: RenderPipeline;
|
|
230
|
+
/** Estimated cell height in px (default: 120) */
|
|
231
|
+
estimatedHeight?: number;
|
|
232
|
+
/** Number of cells to render above/below viewport (default: 5) */
|
|
233
|
+
overscan?: number;
|
|
234
|
+
}
|
|
235
|
+
declare const VirtualRenderer: React__default.FC<VirtualRendererProps>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* MermaidCell — Renders Mermaid diagrams asynchronously.
|
|
239
|
+
*
|
|
240
|
+
* Uses globalThis.mermaid (consumer must import and expose mermaid).
|
|
241
|
+
* Handles async mermaid.render() from v10+.
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
interface MermaidPreviewProps {
|
|
245
|
+
source: string;
|
|
246
|
+
onClick?: () => void;
|
|
247
|
+
}
|
|
248
|
+
declare const MermaidPreview: React__default.FC<MermaidPreviewProps>;
|
|
249
|
+
/**
|
|
250
|
+
* Initialize mermaid globally. Call this once in your app entry point.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import mermaid from "mermaid";
|
|
255
|
+
* import { initMermaid } from "@velo-sci/notebook-react";
|
|
256
|
+
* initMermaid(mermaid);
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
declare function initMermaid(mermaidLib: any, config?: Record<string, unknown>): void;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* AI Rewrite Flow for sci-notebook.
|
|
263
|
+
*
|
|
264
|
+
* Flow: select text → prompt → preview diff → accept/reject
|
|
265
|
+
*
|
|
266
|
+
* This component renders as a floating panel near the selected text,
|
|
267
|
+
* allowing the user to provide a rewrite instruction and preview the result.
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
interface AIRewriteProps {
|
|
271
|
+
/** The currently selected text to rewrite */
|
|
272
|
+
selectedText: string;
|
|
273
|
+
/** Position to render the panel */
|
|
274
|
+
position: {
|
|
275
|
+
top: number;
|
|
276
|
+
left: number;
|
|
277
|
+
};
|
|
278
|
+
/** Called with the rewrite instruction; should return rewritten text */
|
|
279
|
+
onRewrite: (instruction: string, selectedText: string) => Promise<string>;
|
|
280
|
+
/** Called when user accepts the rewrite */
|
|
281
|
+
onAccept: (newText: string) => void;
|
|
282
|
+
/** Called when user rejects / closes */
|
|
283
|
+
onReject: () => void;
|
|
284
|
+
}
|
|
285
|
+
declare const AIRewrite: React__default.FC<AIRewriteProps>;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* AI Cell Generation UI for sci-notebook.
|
|
289
|
+
*
|
|
290
|
+
* Flow: prompt → generate → preview → insert cells
|
|
291
|
+
*
|
|
292
|
+
* Renders as a modal/inline panel where the user types a prompt,
|
|
293
|
+
* the AI generates one or more cells, and the user can accept or reject.
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
interface GeneratedCell {
|
|
297
|
+
type: CellType;
|
|
298
|
+
source: string;
|
|
299
|
+
}
|
|
300
|
+
interface AICellGenerateProps {
|
|
301
|
+
/** Called with the prompt; should return generated cells */
|
|
302
|
+
onGenerate: (prompt: string) => Promise<GeneratedCell[]>;
|
|
303
|
+
/** Called when user accepts the generated cells */
|
|
304
|
+
onAccept: (cells: GeneratedCell[]) => void;
|
|
305
|
+
/** Called when user closes without accepting */
|
|
306
|
+
onCancel: () => void;
|
|
307
|
+
/** Insert position index */
|
|
308
|
+
insertIndex: number;
|
|
309
|
+
}
|
|
310
|
+
declare const AICellGenerate: React__default.FC<AICellGenerateProps>;
|
|
311
|
+
|
|
312
|
+
export { AICellGenerate, type AICellGenerateProps, AIRewrite, type AIRewriteProps, Cell, CellOutputDisplay, type CellProps, type ChatMessage, ChatSidebar, type ChatSidebarProps, DEFAULT_COMMANDS, EmbedCell, type FindMatch, FindReplace, FloatingToolbar, type GeneratedCell, GhostText, ImageCell, ImageResize, InsertHandle, LATEX_COMMANDS, LatexAutocomplete, MathEditor, MermaidPreview, NotebookContext, SciNotebook, type SciNotebookProps, SlashCommand, type SlashCommandItem, type TOCItem, TOCSidebar, TableCell, VirtualRenderer, initMermaid, renderEmbedPreview, renderImagePreview, renderTablePreview, useCell, useFocusedCell, useNotebook, useNotebookEvent, useSciNotebook };
|