1 | import { NotificationHandler1, Event, DocumentUri, URI, Disposable, DidOpenNotebookDocumentParams, DidChangeNotebookDocumentParams, DidSaveNotebookDocumentParams, DidCloseNotebookDocumentParams, NotebookDocument, NotebookCell, LSPObject } from 'vscode-languageserver-protocol';
|
2 | import type { Feature, _Notebooks, Connection } from './server';
|
3 | import { TextDocuments, TextDocumentsConfiguration } from './textDocuments';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export interface NotebookSyncFeatureShape {
|
10 | synchronization: {
|
11 | onDidOpenNotebookDocument(handler: NotificationHandler1<DidOpenNotebookDocumentParams>): Disposable;
|
12 | onDidChangeNotebookDocument(handler: NotificationHandler1<DidChangeNotebookDocumentParams>): Disposable;
|
13 | onDidSaveNotebookDocument(handler: NotificationHandler1<DidSaveNotebookDocumentParams>): Disposable;
|
14 | onDidCloseNotebookDocument(handler: NotificationHandler1<DidCloseNotebookDocumentParams>): Disposable;
|
15 | };
|
16 | }
|
17 | export declare const NotebookSyncFeature: Feature<_Notebooks, NotebookSyncFeatureShape>;
|
18 | export type NotebookDocumentChangeEvent = {
|
19 | |
20 |
|
21 |
|
22 | notebookDocument: NotebookDocument;
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 | metadata?: {
|
29 | old: LSPObject | undefined;
|
30 | new: LSPObject | undefined;
|
31 | };
|
32 | |
33 |
|
34 |
|
35 | cells?: {
|
36 | |
37 |
|
38 |
|
39 | added: NotebookCell[];
|
40 | |
41 |
|
42 |
|
43 | removed: NotebookCell[];
|
44 | |
45 |
|
46 |
|
47 | changed: {
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 | data: {
|
54 | old: NotebookCell;
|
55 | new: NotebookCell;
|
56 | }[];
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 | textContent: NotebookCell[];
|
63 | };
|
64 | };
|
65 | };
|
66 | export declare class NotebookDocuments<T extends {
|
67 | uri: DocumentUri;
|
68 | }> {
|
69 | private readonly notebookDocuments;
|
70 | private readonly notebookCellMap;
|
71 | private readonly _onDidOpen;
|
72 | private readonly _onDidSave;
|
73 | private readonly _onDidChange;
|
74 | private readonly _onDidClose;
|
75 | private _cellTextDocuments;
|
76 | constructor(configurationOrTextDocuments: TextDocumentsConfiguration<T> | TextDocuments<T>);
|
77 | get cellTextDocuments(): TextDocuments<T>;
|
78 | getCellTextDocument(cell: NotebookCell): T | undefined;
|
79 | getNotebookDocument(uri: URI): NotebookDocument | undefined;
|
80 | getNotebookCell(uri: DocumentUri): NotebookCell | undefined;
|
81 | findNotebookDocumentForCell(cell: DocumentUri | NotebookCell): NotebookDocument | undefined;
|
82 | get onDidOpen(): Event<NotebookDocument>;
|
83 | get onDidSave(): Event<NotebookDocument>;
|
84 | get onDidChange(): Event<NotebookDocumentChangeEvent>;
|
85 | get onDidClose(): Event<NotebookDocument>;
|
86 | /**
|
87 | * Listens for `low level` notification on the given connection to
|
88 | * update the notebook documents managed by this instance.
|
89 | *
|
90 | * Please note that the connection only provides handlers not an event model. Therefore
|
91 | * listening on a connection will overwrite the following handlers on a connection:
|
92 | * `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
|
93 | * and `onDidCloseNotebookDocument`.
|
94 | *
|
95 | * @param connection The connection to listen on.
|
96 | */
|
97 | listen(connection: Connection): Disposable;
|
98 | private updateCellMap;
|
99 | }
|