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 | *
|
51 | * @param position - the position of cursor in the virtual document.
|
52 | */
|
53 | getEditorIndexAt(position: IVirtualPosition): number;
|
54 | /**
|
55 | * Get the index of input editor
|
56 | *
|
57 | * @param ceEditor - instance of the code editor
|
58 | */
|
59 | getEditorIndex(ceEditor: Document.IEditor): number;
|
60 | /**
|
61 | * Get the wrapper of input editor.
|
62 | *
|
63 | * @param ceEditor - instance of the code editor
|
64 | */
|
65 | getEditorWrapper(ceEditor: Document.IEditor): HTMLElement;
|
66 | /**
|
67 | * Callback on kernel changed event, it will disconnect the
|
68 | * document with the language server and then reconnect.
|
69 | *
|
70 | * @param _session - Session context of changed kernel
|
71 | * @param change - Changed data
|
72 | */
|
73 | onKernelChanged(_session: SessionContext, change: Session.ISessionConnection.IKernelChangedArgs): Promise<void>;
|
74 | /**
|
75 | * Dispose the widget.
|
76 | */
|
77 | dispose(): void;
|
78 | /**
|
79 | * Method to check if the notebook context is ready.
|
80 | */
|
81 | isReady(): boolean;
|
82 | /**
|
83 | * Update the virtual document on cell changing event.
|
84 | *
|
85 | * @param cells - Observable list of changed cells
|
86 | * @param change - Changed data
|
87 | */
|
88 | handleCellChange(cells: CellList, change: IObservableList.IChangedArgs<ICellModel>): Promise<void>;
|
89 | /**
|
90 | * Generate the virtual document associated with the document.
|
91 | */
|
92 | createVirtualDocument(): VirtualDocument;
|
93 | /**
|
94 | * Get the metadata of notebook.
|
95 | */
|
96 | protected language_info(): ILanguageInfoMetadata;
|
97 | /**
|
98 | * Initialization function called once the editor and the LSP connection
|
99 | * manager is ready. This function will create the virtual document and
|
100 | * connect various signals.
|
101 | */
|
102 | protected initOnceReady(): Promise<void>;
|
103 | /**
|
104 | * Connect the cell changed event to its handler
|
105 | *
|
106 | * @param notebook - The notebook that emitted event.
|
107 | */
|
108 | private _connectModelSignals;
|
109 | /**
|
110 | * Update the stored language info with the one from the notebook.
|
111 | */
|
112 | private _updateLanguageInfo;
|
113 | /**
|
114 | * Handle the cell changed event
|
115 | * @param notebook - The notebook that emitted event
|
116 | * @param cell - Changed cell.
|
117 | */
|
118 | private _activeCellChanged;
|
119 | /**
|
120 | * Get the cell at the cursor position of the virtual document.
|
121 | * @param pos - Position in the virtual document.
|
122 | */
|
123 | private _getCellAt;
|
124 | /**
|
125 | * Get the cell editor and add new ones to the mappings.
|
126 | *
|
127 | * @param cell Cell widget
|
128 | * @returns Cell editor accessor
|
129 | */
|
130 | private _getCellEditor;
|
131 | /**
|
132 | * A map between the editor accessor and the containing cell
|
133 | */
|
134 | private _editorToCell;
|
135 | /**
|
136 | * Mapping of cell to editor accessor to ensure accessor uniqueness.
|
137 | */
|
138 | private _cellToEditor;
|
139 | /**
|
140 | * Metadata of the notebook
|
141 | */
|
142 | private _languageInfo;
|
143 | private _type;
|
144 | private _readyDelegate;
|
145 | }
|
146 | export {};
|