1 | import { SessionContext } from '@jupyterlab/apputils';
|
2 | import { ICellModel } from '@jupyterlab/cells';
|
3 | import { Document, IAdapterOptions, IVirtualPosition, VirtualDocument, WidgetLSPAdapter } from '@jupyterlab/lsp';
|
4 | import * as nbformat from '@jupyterlab/nbformat';
|
5 | import { IObservableList } from '@jupyterlab/observables';
|
6 | import { Session } from '@jupyterlab/services';
|
7 | import { NotebookPanel } from './panel';
|
8 | import { Notebook } from './widget';
|
9 | import { CellList } from './celllist';
|
10 | type ILanguageInfoMetadata = nbformat.ILanguageInfoMetadata;
|
11 | export declare class NotebookAdapter extends WidgetLSPAdapter<NotebookPanel> {
|
12 | editorWidget: NotebookPanel;
|
13 | protected options: IAdapterOptions;
|
14 | constructor(editorWidget: NotebookPanel, options: IAdapterOptions);
|
15 | /**
|
16 | * The wrapped `Notebook` widget.
|
17 | */
|
18 | readonly editor: Notebook;
|
19 | /**
|
20 | * Get current path of the document.
|
21 | */
|
22 | get documentPath(): string;
|
23 | /**
|
24 | * Get the mime type of the document.
|
25 | */
|
26 | get mimeType(): string;
|
27 | /**
|
28 | * Get the file extension of the document.
|
29 | */
|
30 | get languageFileExtension(): string | undefined;
|
31 | /**
|
32 | * Get the inner HTMLElement of the document widget.
|
33 | */
|
34 | get wrapperElement(): HTMLElement;
|
35 | /**
|
36 | * Get the list of CM editor with its type in the document,
|
37 | */
|
38 | get editors(): Document.ICodeBlockOptions[];
|
39 | /**
|
40 | * Get the activated CM editor.
|
41 | */
|
42 | get activeEditor(): Document.IEditor | undefined;
|
43 | /**
|
44 | * Promise that resolves once the adapter is initialized
|
45 | */
|
46 | get ready(): Promise<void>;
|
47 | /**
|
48 | * Get the index of editor from the cursor position in the virtual
|
49 | * document.
|
50 | * @deprecated This is error-prone and will be removed in JupyterLab 5.0, use `getEditorIndex()` with `virtualDocument.getEditorAtVirtualLine(position)` instead.
|
51 | *
|
52 | * @param position - the position of cursor in the virtual document.
|
53 | */
|
54 | getEditorIndexAt(position: IVirtualPosition): number;
|
55 | /**
|
56 | * Get the index of input editor
|
57 | *
|
58 | * @param ceEditor - instance of the code editor
|
59 | */
|
60 | getEditorIndex(ceEditor: Document.IEditor): number;
|
61 | /**
|
62 | * Get the wrapper of input editor.
|
63 | *
|
64 | * @param ceEditor - instance of the code editor
|
65 | */
|
66 | getEditorWrapper(ceEditor: Document.IEditor): HTMLElement;
|
67 | /**
|
68 | * Callback on kernel changed event, it will disconnect the
|
69 | * document with the language server and then reconnect.
|
70 | *
|
71 | * @param _session - Session context of changed kernel
|
72 | * @param change - Changed data
|
73 | */
|
74 | onKernelChanged(_session: SessionContext, change: Session.ISessionConnection.IKernelChangedArgs): Promise<void>;
|
75 | /**
|
76 | * Dispose the widget.
|
77 | */
|
78 | dispose(): void;
|
79 | /**
|
80 | * Method to check if the notebook context is ready.
|
81 | */
|
82 | isReady(): boolean;
|
83 | /**
|
84 | * Update the virtual document on cell changing event.
|
85 | *
|
86 | * @param cells - Observable list of changed cells
|
87 | * @param change - Changed data
|
88 | */
|
89 | handleCellChange(cells: CellList, change: IObservableList.IChangedArgs<ICellModel>): Promise<void>;
|
90 | /**
|
91 | * Generate the virtual document associated with the document.
|
92 | */
|
93 | createVirtualDocument(): VirtualDocument;
|
94 | /**
|
95 | * Get the metadata of notebook.
|
96 | */
|
97 | protected language_info(): ILanguageInfoMetadata;
|
98 | /**
|
99 | * Initialization function called once the editor and the LSP connection
|
100 | * manager is ready. This function will create the virtual document and
|
101 | * connect various signals.
|
102 | */
|
103 | protected initOnceReady(): Promise<void>;
|
104 | /**
|
105 | * Connect the cell changed event to its handler
|
106 | *
|
107 | * @param notebook - The notebook that emitted event.
|
108 | */
|
109 | private _connectModelSignals;
|
110 | /**
|
111 | * Update the stored language info with the one from the notebook.
|
112 | */
|
113 | private _updateLanguageInfo;
|
114 | /**
|
115 | * Handle the cell changed event
|
116 | * @param notebook - The notebook that emitted event
|
117 | * @param cell - Changed cell.
|
118 | */
|
119 | private _activeCellChanged;
|
120 | /**
|
121 | * Get the cell at the cursor position of the virtual document.
|
122 | * @param pos - Position in the virtual document.
|
123 | */
|
124 | private _getCellAt;
|
125 | /**
|
126 | * Get the cell editor and add new ones to the mappings.
|
127 | *
|
128 | * @param cell Cell widget
|
129 | * @returns Cell editor accessor
|
130 | */
|
131 | private _getCellEditor;
|
132 | /**
|
133 | * A map between the editor accessor and the containing cell
|
134 | */
|
135 | private _editorToCell;
|
136 | /**
|
137 | * Mapping of cell to editor accessor to ensure accessor uniqueness.
|
138 | */
|
139 | private _cellToEditor;
|
140 | /**
|
141 | * Metadata of the notebook
|
142 | */
|
143 | private _languageInfo;
|
144 | private _type;
|
145 | private _readyDelegate;
|
146 | }
|
147 | export {};
|