@theia/notebook 1.47.1 → 1.48.2
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/lib/browser/contributions/cell-operations.d.ts +8 -0
- package/lib/browser/contributions/cell-operations.d.ts.map +1 -0
- package/lib/browser/contributions/cell-operations.js +37 -0
- package/lib/browser/contributions/cell-operations.js.map +1 -0
- package/lib/browser/contributions/notebook-actions-contribution.d.ts +10 -2
- package/lib/browser/contributions/notebook-actions-contribution.d.ts.map +1 -1
- package/lib/browser/contributions/notebook-actions-contribution.js +61 -7
- package/lib/browser/contributions/notebook-actions-contribution.js.map +1 -1
- package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts +16 -1
- package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts.map +1 -1
- package/lib/browser/contributions/notebook-cell-actions-contribution.js +154 -17
- package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +1 -1
- package/lib/browser/notebook-editor-widget.d.ts +8 -2
- package/lib/browser/notebook-editor-widget.d.ts.map +1 -1
- package/lib/browser/notebook-editor-widget.js +38 -13
- package/lib/browser/notebook-editor-widget.js.map +1 -1
- package/lib/browser/notebook-frontend-module.d.ts.map +1 -1
- package/lib/browser/notebook-frontend-module.js +6 -9
- package/lib/browser/notebook-frontend-module.js.map +1 -1
- package/lib/browser/notebook-types.d.ts +10 -2
- package/lib/browser/notebook-types.d.ts.map +1 -1
- package/lib/browser/notebook-types.js.map +1 -1
- package/lib/browser/service/notebook-context-manager.d.ts +24 -0
- package/lib/browser/service/notebook-context-manager.d.ts.map +1 -0
- package/lib/browser/service/notebook-context-manager.js +112 -0
- package/lib/browser/service/notebook-context-manager.js.map +1 -0
- package/lib/browser/service/notebook-editor-widget-service.d.ts +3 -0
- package/lib/browser/service/notebook-editor-widget-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-editor-widget-service.js +21 -11
- package/lib/browser/service/notebook-editor-widget-service.js.map +1 -1
- package/lib/browser/service/notebook-kernel-service.d.ts +1 -0
- package/lib/browser/service/notebook-kernel-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-kernel-service.js +6 -3
- package/lib/browser/service/notebook-kernel-service.js.map +1 -1
- package/lib/browser/service/notebook-monaco-text-model-service.d.ts +16 -0
- package/lib/browser/service/notebook-monaco-text-model-service.d.ts.map +1 -0
- package/lib/browser/service/notebook-monaco-text-model-service.js +49 -0
- package/lib/browser/service/notebook-monaco-text-model-service.js.map +1 -0
- package/lib/browser/service/notebook-service.d.ts +10 -2
- package/lib/browser/service/notebook-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-service.js +19 -6
- package/lib/browser/service/notebook-service.js.map +1 -1
- package/lib/browser/view/notebook-cell-editor.d.ts +7 -0
- package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -1
- package/lib/browser/view/notebook-cell-editor.js +43 -3
- package/lib/browser/view/notebook-cell-editor.js.map +1 -1
- package/lib/browser/view/notebook-cell-list-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-cell-list-view.js +6 -3
- package/lib/browser/view/notebook-cell-list-view.js.map +1 -1
- package/lib/browser/view/notebook-cell-toolbar-factory.d.ts +2 -0
- package/lib/browser/view/notebook-cell-toolbar-factory.d.ts.map +1 -1
- package/lib/browser/view/notebook-cell-toolbar-factory.js +12 -6
- package/lib/browser/view/notebook-cell-toolbar-factory.js.map +1 -1
- package/lib/browser/view/notebook-cell-toolbar.js +1 -1
- package/lib/browser/view/notebook-cell-toolbar.js.map +1 -1
- package/lib/browser/view/notebook-code-cell-view.d.ts +11 -0
- package/lib/browser/view/notebook-code-cell-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-code-cell-view.js +52 -4
- package/lib/browser/view/notebook-code-cell-view.js.map +1 -1
- package/lib/browser/view/notebook-main-toolbar.d.ts +6 -1
- package/lib/browser/view/notebook-main-toolbar.d.ts.map +1 -1
- package/lib/browser/view/notebook-main-toolbar.js +23 -5
- package/lib/browser/view/notebook-main-toolbar.js.map +1 -1
- package/lib/browser/view/notebook-markdown-cell-view.d.ts +2 -0
- package/lib/browser/view/notebook-markdown-cell-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-markdown-cell-view.js +9 -4
- package/lib/browser/view/notebook-markdown-cell-view.js.map +1 -1
- package/lib/browser/view/notebook-viewport-service.d.ts +17 -0
- package/lib/browser/view/notebook-viewport-service.d.ts.map +1 -0
- package/lib/browser/view/notebook-viewport-service.js +60 -0
- package/lib/browser/view/notebook-viewport-service.js.map +1 -0
- package/lib/browser/view-model/notebook-cell-model.d.ts +9 -15
- package/lib/browser/view-model/notebook-cell-model.d.ts.map +1 -1
- package/lib/browser/view-model/notebook-cell-model.js +22 -23
- package/lib/browser/view-model/notebook-cell-model.js.map +1 -1
- package/lib/browser/view-model/notebook-model.d.ts +7 -4
- package/lib/browser/view-model/notebook-model.d.ts.map +1 -1
- package/lib/browser/view-model/notebook-model.js +50 -6
- package/lib/browser/view-model/notebook-model.js.map +1 -1
- package/lib/common/notebook-common.d.ts +7 -0
- package/lib/common/notebook-common.d.ts.map +1 -1
- package/lib/common/notebook-common.js +12 -1
- package/lib/common/notebook-common.js.map +1 -1
- package/package.json +8 -7
- package/src/browser/contributions/cell-operations.ts +38 -0
- package/src/browser/contributions/notebook-actions-contribution.ts +66 -6
- package/src/browser/contributions/notebook-cell-actions-contribution.ts +194 -22
- package/src/browser/notebook-editor-widget.tsx +43 -17
- package/src/browser/notebook-frontend-module.ts +8 -11
- package/src/browser/notebook-types.ts +13 -1
- package/src/browser/service/notebook-context-manager.ts +127 -0
- package/src/browser/service/notebook-editor-widget-service.ts +20 -10
- package/src/browser/service/notebook-kernel-service.ts +6 -2
- package/src/browser/service/notebook-monaco-text-model-service.ts +48 -0
- package/src/browser/service/notebook-service.ts +26 -5
- package/src/browser/style/index.css +25 -8
- package/src/browser/view/notebook-cell-editor.tsx +52 -10
- package/src/browser/view/notebook-cell-list-view.tsx +8 -4
- package/src/browser/view/notebook-cell-toolbar-factory.tsx +9 -4
- package/src/browser/view/notebook-cell-toolbar.tsx +1 -1
- package/src/browser/view/notebook-code-cell-view.tsx +64 -8
- package/src/browser/view/notebook-main-toolbar.tsx +26 -5
- package/src/browser/view/notebook-markdown-cell-view.tsx +9 -4
- package/src/browser/view/notebook-viewport-service.ts +61 -0
- package/src/browser/view-model/notebook-cell-model.ts +26 -33
- package/src/browser/view-model/notebook-model.ts +70 -7
- package/src/common/notebook-common.ts +13 -0
- package/lib/browser/service/notebook-cell-context-manager.d.ts +0 -16
- package/lib/browser/service/notebook-cell-context-manager.d.ts.map +0 -1
- package/lib/browser/service/notebook-cell-context-manager.js +0 -74
- package/lib/browser/service/notebook-cell-context-manager.js.map +0 -1
- package/src/browser/service/notebook-cell-context-manager.ts +0 -72
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
import { Command, CommandContribution, CommandHandler, CommandRegistry, CompoundMenuNodeRole, MenuContribution, MenuModelRegistry, nls } from '@theia/core';
|
|
18
18
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { ApplicationShell, codicon, CommonCommands } from '@theia/core/lib/browser';
|
|
19
|
+
import { ApplicationShell, codicon, CommonCommands, KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser';
|
|
20
20
|
import { NotebookModel } from '../view-model/notebook-model';
|
|
21
21
|
import { NotebookService } from '../service/notebook-service';
|
|
22
22
|
import { CellEditType, CellKind, NotebookCommand } from '../../common';
|
|
23
23
|
import { NotebookKernelQuickPickService } from '../service/notebook-kernel-quick-pick-service';
|
|
24
24
|
import { NotebookExecutionService } from '../service/notebook-execution-service';
|
|
25
25
|
import { NotebookEditorWidget } from '../notebook-editor-widget';
|
|
26
|
+
import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
|
|
27
|
+
import { NOTEBOOK_CELL_FOCUSED, NOTEBOOK_EDITOR_FOCUSED } from './notebook-context-keys';
|
|
26
28
|
|
|
27
29
|
export namespace NotebookCommands {
|
|
28
30
|
export const ADD_NEW_CELL_COMMAND = Command.toDefaultLocalizedCommand({
|
|
@@ -59,10 +61,20 @@ export namespace NotebookCommands {
|
|
|
59
61
|
category: 'Notebook',
|
|
60
62
|
iconClass: codicon('clear-all')
|
|
61
63
|
});
|
|
64
|
+
|
|
65
|
+
export const CHANGE_SELECTED_CELL = Command.toDefaultLocalizedCommand({
|
|
66
|
+
id: 'notebook.change-selected-cell',
|
|
67
|
+
category: 'Notebook',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export enum CellChangeDirection {
|
|
72
|
+
Up = 'up',
|
|
73
|
+
Down = 'down'
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
@injectable()
|
|
65
|
-
export class NotebookActionsContribution implements CommandContribution, MenuContribution {
|
|
77
|
+
export class NotebookActionsContribution implements CommandContribution, MenuContribution, KeybindingContribution {
|
|
66
78
|
|
|
67
79
|
@inject(NotebookService)
|
|
68
80
|
protected notebookService: NotebookService;
|
|
@@ -76,10 +88,22 @@ export class NotebookActionsContribution implements CommandContribution, MenuCon
|
|
|
76
88
|
@inject(ApplicationShell)
|
|
77
89
|
protected shell: ApplicationShell;
|
|
78
90
|
|
|
91
|
+
@inject(NotebookEditorWidgetService)
|
|
92
|
+
protected notebookEditorWidgetService: NotebookEditorWidgetService;
|
|
93
|
+
|
|
79
94
|
registerCommands(commands: CommandRegistry): void {
|
|
80
95
|
commands.registerCommand(NotebookCommands.ADD_NEW_CELL_COMMAND, {
|
|
81
|
-
execute: (notebookModel: NotebookModel, cellKind: CellKind, index?: number) => {
|
|
82
|
-
|
|
96
|
+
execute: (notebookModel: NotebookModel, cellKind: CellKind = CellKind.Markup, index?: number | 'above' | 'below') => {
|
|
97
|
+
notebookModel = notebookModel ?? this.notebookEditorWidgetService.focusedEditor?.model;
|
|
98
|
+
|
|
99
|
+
let insertIndex: number = 0;
|
|
100
|
+
if (index && index >= 0) {
|
|
101
|
+
insertIndex = index as number;
|
|
102
|
+
} else if (notebookModel.selectedCell && typeof index === 'string') {
|
|
103
|
+
// if index is -1 insert below otherwise at the index of the selected cell which is above the selected.
|
|
104
|
+
insertIndex = notebookModel.cells.indexOf(notebookModel.selectedCell) + (index === 'below' ? 1 : 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
83
107
|
let firstCodeCell;
|
|
84
108
|
if (cellKind === CellKind.Code) {
|
|
85
109
|
firstCodeCell = notebookModel.cells.find(cell => cell.cellKind === CellKind.Code);
|
|
@@ -101,11 +125,11 @@ export class NotebookActionsContribution implements CommandContribution, MenuCon
|
|
|
101
125
|
});
|
|
102
126
|
|
|
103
127
|
commands.registerCommand(NotebookCommands.ADD_NEW_MARKDOWN_CELL_COMMAND, this.editableCommandHandler(
|
|
104
|
-
notebookModel => commands.executeCommand(NotebookCommands.ADD_NEW_CELL_COMMAND.id, notebookModel, CellKind.Markup)
|
|
128
|
+
notebookModel => commands.executeCommand(NotebookCommands.ADD_NEW_CELL_COMMAND.id, notebookModel, CellKind.Markup, 'below')
|
|
105
129
|
));
|
|
106
130
|
|
|
107
131
|
commands.registerCommand(NotebookCommands.ADD_NEW_CODE_CELL_COMMAND, this.editableCommandHandler(
|
|
108
|
-
notebookModel => commands.executeCommand(NotebookCommands.ADD_NEW_CELL_COMMAND.id, notebookModel, CellKind.Code)
|
|
132
|
+
notebookModel => commands.executeCommand(NotebookCommands.ADD_NEW_CELL_COMMAND.id, notebookModel, CellKind.Code, 'below')
|
|
109
133
|
));
|
|
110
134
|
|
|
111
135
|
commands.registerCommand(NotebookCommands.SELECT_KERNEL_COMMAND, this.editableCommandHandler(
|
|
@@ -120,6 +144,24 @@ export class NotebookActionsContribution implements CommandContribution, MenuCon
|
|
|
120
144
|
notebookModel => notebookModel.cells.forEach(cell => cell.spliceNotebookCellOutputs({ start: 0, deleteCount: cell.outputs.length, newOutputs: [] }))
|
|
121
145
|
));
|
|
122
146
|
|
|
147
|
+
commands.registerCommand(NotebookCommands.CHANGE_SELECTED_CELL,
|
|
148
|
+
{
|
|
149
|
+
execute: (change: number | CellChangeDirection) => {
|
|
150
|
+
const model = this.notebookEditorWidgetService.focusedEditor?.model;
|
|
151
|
+
if (model && typeof change === 'number') {
|
|
152
|
+
model.setSelectedCell(model.cells[change]);
|
|
153
|
+
} else if (model && model.selectedCell) {
|
|
154
|
+
const currentIndex = model.cells.indexOf(model.selectedCell);
|
|
155
|
+
if (change === CellChangeDirection.Up && currentIndex > 0) {
|
|
156
|
+
model.setSelectedCell(model.cells[currentIndex - 1]);
|
|
157
|
+
} else if (change === CellChangeDirection.Down && currentIndex < model.cells.length - 1) {
|
|
158
|
+
model.setSelectedCell(model.cells[currentIndex + 1]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
|
|
123
165
|
commands.registerHandler(CommonCommands.UNDO.id, {
|
|
124
166
|
isEnabled: () => {
|
|
125
167
|
const widget = this.shell.activeWidget;
|
|
@@ -134,6 +176,7 @@ export class NotebookActionsContribution implements CommandContribution, MenuCon
|
|
|
134
176
|
},
|
|
135
177
|
execute: () => (this.shell.activeWidget as NotebookEditorWidget).redo()
|
|
136
178
|
});
|
|
179
|
+
|
|
137
180
|
}
|
|
138
181
|
|
|
139
182
|
protected editableCommandHandler(execute: (notebookModel: NotebookModel) => void): CommandHandler {
|
|
@@ -179,6 +222,23 @@ export class NotebookActionsContribution implements CommandContribution, MenuCon
|
|
|
179
222
|
// other items
|
|
180
223
|
}
|
|
181
224
|
|
|
225
|
+
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
226
|
+
keybindings.registerKeybindings(
|
|
227
|
+
{
|
|
228
|
+
command: NotebookCommands.CHANGE_SELECTED_CELL.id,
|
|
229
|
+
keybinding: 'up',
|
|
230
|
+
args: CellChangeDirection.Up,
|
|
231
|
+
when: `!editorTextFocus && ${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED}`
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
command: NotebookCommands.CHANGE_SELECTED_CELL.id,
|
|
235
|
+
keybinding: 'down',
|
|
236
|
+
args: CellChangeDirection.Down,
|
|
237
|
+
when: `!editorTextFocus && ${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED}`
|
|
238
|
+
},
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
182
242
|
}
|
|
183
243
|
|
|
184
244
|
export namespace NotebookMenus {
|
|
@@ -15,15 +15,22 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Command, CommandContribution, CommandHandler, CommandRegistry, CompoundMenuNodeRole, MenuContribution, MenuModelRegistry, nls } from '@theia/core';
|
|
18
|
-
import { codicon } from '@theia/core/lib/browser';
|
|
18
|
+
import { codicon, Key, KeybindingContribution, KeybindingRegistry, KeyCode, KeyModifier } from '@theia/core/lib/browser';
|
|
19
19
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
20
20
|
import { NotebookModel } from '../view-model/notebook-model';
|
|
21
21
|
import { NotebookCellModel } from '../view-model/notebook-cell-model';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_TYPE,
|
|
24
|
+
NotebookContextKeys, NOTEBOOK_CELL_EXECUTING, NOTEBOOK_EDITOR_FOCUSED,
|
|
25
|
+
NOTEBOOK_CELL_FOCUSED, NOTEBOOK_CELL_EDITABLE
|
|
26
|
+
} from './notebook-context-keys';
|
|
23
27
|
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
24
28
|
import { NotebookExecutionService } from '../service/notebook-execution-service';
|
|
25
29
|
import { NotebookCellOutputModel } from '../view-model/notebook-cell-output-model';
|
|
26
|
-
import { CellEditType } from '../../common';
|
|
30
|
+
import { CellEditType, CellKind } from '../../common';
|
|
31
|
+
import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
|
|
32
|
+
import { NotebookCommands } from './notebook-actions-contribution';
|
|
33
|
+
import { changeCellType } from './cell-operations';
|
|
27
34
|
|
|
28
35
|
export namespace NotebookCellCommands {
|
|
29
36
|
/** Parameters: notebookModel: NotebookModel | undefined, cell: NotebookCellModel */
|
|
@@ -52,6 +59,22 @@ export namespace NotebookCellCommands {
|
|
|
52
59
|
iconClass: codicon('play'),
|
|
53
60
|
});
|
|
54
61
|
/** Parameters: notebookModel: NotebookModel, cell: NotebookCellModel */
|
|
62
|
+
export const EXECUTE_SINGLE_CELL_AND_FOCUS_NEXT_COMMAND = Command.toDefaultLocalizedCommand({
|
|
63
|
+
id: 'notebook.cell.execute-cell-and-focus-next',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const EXECUTE_ABOVE_CELLS_COMMAND = Command.toDefaultLocalizedCommand({
|
|
67
|
+
id: 'notebookActions.executeAbove',
|
|
68
|
+
label: 'Execute Above Cells',
|
|
69
|
+
iconClass: codicon('run-above')
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const EXECUTE_CELL_AND_BELOW_COMMAND = Command.toDefaultLocalizedCommand({
|
|
73
|
+
id: 'notebookActions.executeBelow',
|
|
74
|
+
label: 'Execute Cell and Below',
|
|
75
|
+
iconClass: codicon('run-below')
|
|
76
|
+
});
|
|
77
|
+
/** Parameters: notebookModel: NotebookModel, cell: NotebookCellModel */
|
|
55
78
|
export const STOP_CELL_EXECUTION_COMMAND = Command.toDefaultLocalizedCommand({
|
|
56
79
|
id: 'notebook.cell.stop-cell-execution',
|
|
57
80
|
iconClass: codicon('stop'),
|
|
@@ -66,10 +89,39 @@ export namespace NotebookCellCommands {
|
|
|
66
89
|
id: 'notebook.cell.change-presentation',
|
|
67
90
|
label: 'Change Presentation',
|
|
68
91
|
});
|
|
92
|
+
|
|
93
|
+
export const INSERT_NEW_CELL_ABOVE_COMMAND = Command.toDefaultLocalizedCommand({
|
|
94
|
+
id: 'notebook.cell.insertCodeCellAboveAndFocusContainer',
|
|
95
|
+
label: 'Insert Code Cell Above and Focus Container'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const INSERT_NEW_CELL_BELOW_COMMAND = Command.toDefaultLocalizedCommand({
|
|
99
|
+
id: 'notebook.cell.insertCodeCellBelowAndFocusContainer',
|
|
100
|
+
label: 'Insert Code Cell Below and Focus Container'
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const INSERT_MARKDOWN_CELL_ABOVE_COMMAND = Command.toLocalizedCommand({
|
|
104
|
+
id: 'notebook.cell.insertMarkdownCellAbove',
|
|
105
|
+
label: 'Insert Markdown Cell Above'
|
|
106
|
+
});
|
|
107
|
+
export const INSERT_MARKDOWN_CELL_BELOW_COMMAND = Command.toLocalizedCommand({
|
|
108
|
+
id: 'notebook.cell.insertMarkdownCellBelow',
|
|
109
|
+
label: 'Insert Markdown Cell Below'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const TO_CODE_CELL_COMMAND = Command.toLocalizedCommand({
|
|
113
|
+
id: 'notebook.cell.to-code-cell',
|
|
114
|
+
label: 'Change Cell to Code'
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const TO_MARKDOWN_CELL_COMMAND = Command.toLocalizedCommand({
|
|
118
|
+
id: 'notebook.cell.to-markdown-cell',
|
|
119
|
+
label: 'Change Cell to Mardown'
|
|
120
|
+
});
|
|
69
121
|
}
|
|
70
122
|
|
|
71
123
|
@injectable()
|
|
72
|
-
export class NotebookCellActionContribution implements MenuContribution, CommandContribution {
|
|
124
|
+
export class NotebookCellActionContribution implements MenuContribution, CommandContribution, KeybindingContribution {
|
|
73
125
|
|
|
74
126
|
@inject(ContextKeyService)
|
|
75
127
|
protected contextKeyService: ContextKeyService;
|
|
@@ -77,6 +129,9 @@ export class NotebookCellActionContribution implements MenuContribution, Command
|
|
|
77
129
|
@inject(NotebookExecutionService)
|
|
78
130
|
protected notebookExecutionService: NotebookExecutionService;
|
|
79
131
|
|
|
132
|
+
@inject(NotebookEditorWidgetService)
|
|
133
|
+
protected notebookEditorWidgetService: NotebookEditorWidgetService;
|
|
134
|
+
|
|
80
135
|
@postConstruct()
|
|
81
136
|
protected init(): void {
|
|
82
137
|
NotebookContextKeys.initNotebookContextKeys(this.contextKeyService);
|
|
@@ -97,20 +152,30 @@ export class NotebookCellActionContribution implements MenuContribution, Command
|
|
|
97
152
|
label: nls.localizeByDefault('Stop Editing Cell'),
|
|
98
153
|
order: '10'
|
|
99
154
|
});
|
|
155
|
+
|
|
100
156
|
menus.registerMenuAction(NotebookCellActionContribution.ACTION_MENU, {
|
|
101
|
-
commandId: NotebookCellCommands.
|
|
102
|
-
icon: NotebookCellCommands.
|
|
157
|
+
commandId: NotebookCellCommands.EXECUTE_ABOVE_CELLS_COMMAND.id,
|
|
158
|
+
icon: NotebookCellCommands.EXECUTE_ABOVE_CELLS_COMMAND.iconClass,
|
|
103
159
|
when: `${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
104
|
-
label: nls.localizeByDefault('Execute
|
|
160
|
+
label: nls.localizeByDefault('Execute Above Cells'),
|
|
105
161
|
order: '10'
|
|
106
162
|
});
|
|
107
163
|
|
|
108
164
|
menus.registerMenuAction(NotebookCellActionContribution.ACTION_MENU, {
|
|
109
|
-
commandId: NotebookCellCommands.
|
|
110
|
-
icon: NotebookCellCommands.
|
|
111
|
-
|
|
165
|
+
commandId: NotebookCellCommands.EXECUTE_CELL_AND_BELOW_COMMAND.id,
|
|
166
|
+
icon: NotebookCellCommands.EXECUTE_CELL_AND_BELOW_COMMAND.iconClass,
|
|
167
|
+
when: `${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
168
|
+
label: nls.localizeByDefault('Execute Cell and Below'),
|
|
112
169
|
order: '20'
|
|
113
170
|
});
|
|
171
|
+
|
|
172
|
+
// menus.registerMenuAction(NotebookCellActionContribution.ACTION_MENU, {
|
|
173
|
+
// commandId: NotebookCellCommands.SPLIT_CELL_COMMAND.id,
|
|
174
|
+
// icon: NotebookCellCommands.SPLIT_CELL_COMMAND.iconClass,
|
|
175
|
+
// label: nls.localizeByDefault('Split Cell'),
|
|
176
|
+
// order: '20'
|
|
177
|
+
// });
|
|
178
|
+
|
|
114
179
|
menus.registerMenuAction(NotebookCellActionContribution.ACTION_MENU, {
|
|
115
180
|
commandId: NotebookCellCommands.DELETE_COMMAND.id,
|
|
116
181
|
icon: NotebookCellCommands.DELETE_COMMAND.iconClass,
|
|
@@ -150,7 +215,7 @@ export class NotebookCellActionContribution implements MenuContribution, Command
|
|
|
150
215
|
menus.registerIndependentSubmenu(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU,
|
|
151
216
|
nls.localizeByDefault('More...'),
|
|
152
217
|
{ role: CompoundMenuNodeRole.Flat, icon: codicon('chevron-down') });
|
|
153
|
-
menus.getMenu(NotebookCellActionContribution.CODE_CELL_SIDEBAR_MENU).addNode(menus.getMenuNode(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU));
|
|
218
|
+
// menus.getMenu(NotebookCellActionContribution.CODE_CELL_SIDEBAR_MENU).addNode(menus.getMenuNode(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU));
|
|
154
219
|
|
|
155
220
|
// code cell output sidebar menu
|
|
156
221
|
menus.registerSubmenu(
|
|
@@ -173,28 +238,83 @@ export class NotebookCellActionContribution implements MenuContribution, Command
|
|
|
173
238
|
|
|
174
239
|
registerCommands(commands: CommandRegistry): void {
|
|
175
240
|
commands.registerCommand(NotebookCellCommands.EDIT_COMMAND, this.editableCellCommandHandler((_, cell) => cell.requestEdit()));
|
|
176
|
-
commands.registerCommand(NotebookCellCommands.STOP_EDIT_COMMAND, { execute: (_, cell: NotebookCellModel) => cell.requestStopEdit() });
|
|
241
|
+
commands.registerCommand(NotebookCellCommands.STOP_EDIT_COMMAND, { execute: (_, cell: NotebookCellModel) => (cell ?? this.getSelectedCell()).requestStopEdit() });
|
|
177
242
|
commands.registerCommand(NotebookCellCommands.DELETE_COMMAND,
|
|
178
|
-
this.editableCellCommandHandler((notebookModel, cell) =>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
243
|
+
this.editableCellCommandHandler((notebookModel, cell) => {
|
|
244
|
+
notebookModel.applyEdits([{
|
|
245
|
+
editType: CellEditType.Replace,
|
|
246
|
+
index: notebookModel.cells.indexOf(cell),
|
|
247
|
+
count: 1,
|
|
248
|
+
cells: []
|
|
249
|
+
}]
|
|
250
|
+
, true);
|
|
251
|
+
}));
|
|
184
252
|
commands.registerCommand(NotebookCellCommands.SPLIT_CELL_COMMAND);
|
|
185
253
|
|
|
186
254
|
commands.registerCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_COMMAND, this.editableCellCommandHandler(
|
|
187
|
-
(notebookModel, cell) =>
|
|
188
|
-
|
|
255
|
+
(notebookModel, cell) => {
|
|
256
|
+
this.notebookExecutionService.executeNotebookCells(notebookModel, [cell]);
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
commands.registerCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_AND_FOCUS_NEXT_COMMAND, this.editableCellCommandHandler(
|
|
261
|
+
(notebookModel, cell) => {
|
|
262
|
+
commands.executeCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_COMMAND.id, notebookModel, cell);
|
|
263
|
+
const index = notebookModel.cells.indexOf(cell);
|
|
264
|
+
if (index < notebookModel.cells.length - 1) {
|
|
265
|
+
notebookModel.setSelectedCell(notebookModel.cells[index + 1]);
|
|
266
|
+
} else {
|
|
267
|
+
commands.executeCommand(NotebookCellCommands.INSERT_NEW_CELL_BELOW_COMMAND.id, notebookModel, CellKind.Code, 'below');
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
commands.registerCommand(NotebookCellCommands.EXECUTE_ABOVE_CELLS_COMMAND, this.editableCellCommandHandler(
|
|
273
|
+
(notebookModel, cell) => {
|
|
274
|
+
const index = notebookModel.cells.indexOf(cell);
|
|
275
|
+
if (index > 0) {
|
|
276
|
+
this.notebookExecutionService.executeNotebookCells(notebookModel, notebookModel.cells.slice(0, index).filter(c => c.cellKind === CellKind.Code));
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
commands.registerCommand(NotebookCellCommands.EXECUTE_CELL_AND_BELOW_COMMAND, this.editableCellCommandHandler(
|
|
282
|
+
(notebookModel, cell) => {
|
|
283
|
+
const index = notebookModel.cells.indexOf(cell);
|
|
284
|
+
if (index < notebookModel.cells.length - 1) {
|
|
285
|
+
this.notebookExecutionService.executeNotebookCells(notebookModel, notebookModel.cells.slice(index).filter(c => c.cellKind === CellKind.Code));
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
|
|
189
290
|
commands.registerCommand(NotebookCellCommands.STOP_CELL_EXECUTION_COMMAND, {
|
|
190
|
-
execute: (notebookModel: NotebookModel, cell: NotebookCellModel) =>
|
|
291
|
+
execute: (notebookModel: NotebookModel, cell: NotebookCellModel) => {
|
|
292
|
+
notebookModel = notebookModel ?? this.notebookEditorWidgetService.focusedEditor?.model;
|
|
293
|
+
cell = cell ?? this.getSelectedCell();
|
|
294
|
+
this.notebookExecutionService.cancelNotebookCells(notebookModel, [cell]);
|
|
295
|
+
}
|
|
191
296
|
});
|
|
192
297
|
commands.registerCommand(NotebookCellCommands.CLEAR_OUTPUTS_COMMAND, this.editableCellCommandHandler(
|
|
193
|
-
(_, cell) => cell.spliceNotebookCellOutputs({ start: 0, deleteCount: cell.outputs.length, newOutputs: [] })
|
|
298
|
+
(_, cell) => cell.spliceNotebookCellOutputs({ start: 0, deleteCount: (cell ?? this.getSelectedCell()).outputs.length, newOutputs: [] })
|
|
194
299
|
));
|
|
195
300
|
commands.registerCommand(NotebookCellCommands.CHANGE_OUTPUT_PRESENTATION_COMMAND, this.editableCellCommandHandler(
|
|
196
301
|
(_, __, output) => output?.requestOutputPresentationUpdate()
|
|
197
302
|
));
|
|
303
|
+
|
|
304
|
+
const insertCommand = (type: CellKind, index: number | 'above' | 'below'): CommandHandler => this.editableCellCommandHandler(() =>
|
|
305
|
+
commands.executeCommand(NotebookCommands.ADD_NEW_CELL_COMMAND.id, undefined, type, index)
|
|
306
|
+
);
|
|
307
|
+
commands.registerCommand(NotebookCellCommands.INSERT_NEW_CELL_ABOVE_COMMAND, insertCommand(CellKind.Code, 'above'));
|
|
308
|
+
commands.registerCommand(NotebookCellCommands.INSERT_NEW_CELL_BELOW_COMMAND, insertCommand(CellKind.Code, 'below'));
|
|
309
|
+
commands.registerCommand(NotebookCellCommands.INSERT_MARKDOWN_CELL_ABOVE_COMMAND, insertCommand(CellKind.Markup, 'above'));
|
|
310
|
+
commands.registerCommand(NotebookCellCommands.INSERT_MARKDOWN_CELL_BELOW_COMMAND, insertCommand(CellKind.Markup, 'below'));
|
|
311
|
+
|
|
312
|
+
commands.registerCommand(NotebookCellCommands.TO_CODE_CELL_COMMAND, this.editableCellCommandHandler((notebookModel, cell) => {
|
|
313
|
+
changeCellType(notebookModel, cell, CellKind.Code);
|
|
314
|
+
}));
|
|
315
|
+
commands.registerCommand(NotebookCellCommands.TO_MARKDOWN_CELL_COMMAND, this.editableCellCommandHandler((notebookModel, cell) => {
|
|
316
|
+
changeCellType(notebookModel, cell, CellKind.Markup);
|
|
317
|
+
}));
|
|
198
318
|
}
|
|
199
319
|
|
|
200
320
|
protected editableCellCommandHandler(execute: (notebookModel: NotebookModel, cell: NotebookCellModel, output?: NotebookCellOutputModel) => void): CommandHandler {
|
|
@@ -202,10 +322,61 @@ export class NotebookCellActionContribution implements MenuContribution, Command
|
|
|
202
322
|
isEnabled: (notebookModel: NotebookModel) => !Boolean(notebookModel?.readOnly),
|
|
203
323
|
isVisible: (notebookModel: NotebookModel) => !Boolean(notebookModel?.readOnly),
|
|
204
324
|
execute: (notebookModel: NotebookModel, cell: NotebookCellModel, output?: NotebookCellOutputModel) => {
|
|
325
|
+
notebookModel = notebookModel ?? this.notebookEditorWidgetService.focusedEditor?.model;
|
|
326
|
+
cell = cell ?? this.getSelectedCell();
|
|
205
327
|
execute(notebookModel, cell, output);
|
|
206
328
|
}
|
|
207
329
|
};
|
|
208
330
|
}
|
|
331
|
+
|
|
332
|
+
protected getSelectedCell(): NotebookCellModel | undefined {
|
|
333
|
+
return this.notebookEditorWidgetService.focusedEditor?.model?.selectedCell;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
337
|
+
keybindings.registerKeybindings(
|
|
338
|
+
{
|
|
339
|
+
command: NotebookCellCommands.EDIT_COMMAND.id,
|
|
340
|
+
keybinding: 'Enter',
|
|
341
|
+
when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_EDITABLE}`,
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
command: NotebookCellCommands.STOP_EDIT_COMMAND.id,
|
|
345
|
+
keybinding: KeyCode.createKeyCode({ first: Key.ENTER, modifiers: [KeyModifier.Alt] }).toString(),
|
|
346
|
+
when: `editorTextFocus && ${NOTEBOOK_EDITOR_FOCUSED}`,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
command: NotebookCellCommands.EXECUTE_SINGLE_CELL_COMMAND.id,
|
|
350
|
+
keybinding: KeyCode.createKeyCode({ first: Key.ENTER, modifiers: [KeyModifier.CtrlCmd] }).toString(),
|
|
351
|
+
when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
command: NotebookCellCommands.EXECUTE_SINGLE_CELL_AND_FOCUS_NEXT_COMMAND.id,
|
|
355
|
+
keybinding: KeyCode.createKeyCode({ first: Key.ENTER, modifiers: [KeyModifier.Shift] }).toString(),
|
|
356
|
+
when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
command: NotebookCellCommands.CLEAR_OUTPUTS_COMMAND.id,
|
|
360
|
+
keybinding: KeyCode.createKeyCode({ first: Key.KEY_O, modifiers: [KeyModifier.Alt] }).toString(),
|
|
361
|
+
when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
command: NotebookCellCommands.CHANGE_OUTPUT_PRESENTATION_COMMAND.id,
|
|
365
|
+
keybinding: KeyCode.createKeyCode({ first: Key.KEY_P, modifiers: [KeyModifier.Alt] }).toString(),
|
|
366
|
+
when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
command: NotebookCellCommands.TO_CODE_CELL_COMMAND.id,
|
|
370
|
+
keybinding: 'Y',
|
|
371
|
+
when: `!editorTextFocus && ${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'markdown'`,
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
command: NotebookCellCommands.TO_MARKDOWN_CELL_COMMAND.id,
|
|
375
|
+
keybinding: 'M',
|
|
376
|
+
when: `!editorTextFocus && ${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'code'`,
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
}
|
|
209
380
|
}
|
|
210
381
|
|
|
211
382
|
export namespace NotebookCellActionContribution {
|
|
@@ -218,3 +389,4 @@ export namespace NotebookCellActionContribution {
|
|
|
218
389
|
export const ADDITIONAL_OUTPUT_SIDEBAR_MENU = [...OUTPUT_SIDEBAR_MENU, 'more'];
|
|
219
390
|
|
|
220
391
|
}
|
|
392
|
+
|
|
@@ -30,7 +30,8 @@ import { NotebookEditorWidgetService } from './service/notebook-editor-widget-se
|
|
|
30
30
|
import { NotebookMainToolbarRenderer } from './view/notebook-main-toolbar';
|
|
31
31
|
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
32
32
|
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
|
|
33
|
-
|
|
33
|
+
import { NotebookContextManager } from './service/notebook-context-manager';
|
|
34
|
+
import { NotebookViewportService } from './view/notebook-viewport-service';
|
|
34
35
|
const PerfectScrollbar = require('react-perfect-scrollbar');
|
|
35
36
|
|
|
36
37
|
export const NotebookEditorWidgetContainerFactory = Symbol('NotebookEditorWidgetContainerFactory');
|
|
@@ -39,12 +40,19 @@ export function createNotebookEditorWidgetContainer(parent: interfaces.Container
|
|
|
39
40
|
const child = parent.createChild();
|
|
40
41
|
|
|
41
42
|
child.bind(NotebookEditorProps).toConstantValue(props);
|
|
43
|
+
|
|
44
|
+
child.bind(NotebookContextManager).toSelf().inSingletonScope();
|
|
45
|
+
child.bind(NotebookMainToolbarRenderer).toSelf().inSingletonScope();
|
|
46
|
+
child.bind(NotebookCodeCellRenderer).toSelf().inSingletonScope();
|
|
47
|
+
child.bind(NotebookMarkdownCellRenderer).toSelf().inSingletonScope();
|
|
48
|
+
child.bind(NotebookViewportService).toSelf().inSingletonScope();
|
|
49
|
+
|
|
42
50
|
child.bind(NotebookEditorWidget).toSelf();
|
|
43
51
|
|
|
44
52
|
return child;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
const NotebookEditorProps = Symbol('NotebookEditorProps');
|
|
55
|
+
export const NotebookEditorProps = Symbol('NotebookEditorProps');
|
|
48
56
|
|
|
49
57
|
interface RenderMessage {
|
|
50
58
|
rendererId: string;
|
|
@@ -79,6 +87,9 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
|
|
|
79
87
|
@inject(NotebookMainToolbarRenderer)
|
|
80
88
|
protected notebookMainToolbarRenderer: NotebookMainToolbarRenderer;
|
|
81
89
|
|
|
90
|
+
@inject(NotebookContextManager)
|
|
91
|
+
protected notebookContextManager: NotebookContextManager;
|
|
92
|
+
|
|
82
93
|
@inject(NotebookCodeCellRenderer)
|
|
83
94
|
protected codeCellRenderer: NotebookCodeCellRenderer;
|
|
84
95
|
@inject(NotebookMarkdownCellRenderer)
|
|
@@ -86,6 +97,9 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
|
|
|
86
97
|
@inject(NotebookEditorProps)
|
|
87
98
|
protected readonly props: NotebookEditorProps;
|
|
88
99
|
|
|
100
|
+
@inject(NotebookViewportService)
|
|
101
|
+
protected readonly viewportService: NotebookViewportService;
|
|
102
|
+
|
|
89
103
|
protected readonly onDidChangeModelEmitter = new Emitter<void>();
|
|
90
104
|
readonly onDidChangeModel = this.onDidChangeModelEmitter.event;
|
|
91
105
|
|
|
@@ -159,6 +173,7 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
|
|
|
159
173
|
// Ensure that the model is loaded before adding the editor
|
|
160
174
|
this.notebookEditorService.addNotebookEditor(this);
|
|
161
175
|
this.update();
|
|
176
|
+
this.notebookContextManager.init(this);
|
|
162
177
|
return this._model;
|
|
163
178
|
}
|
|
164
179
|
|
|
@@ -172,7 +187,7 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
|
|
|
172
187
|
}
|
|
173
188
|
|
|
174
189
|
createMoveToUri(resourceUri: URI): URI | undefined {
|
|
175
|
-
return this.
|
|
190
|
+
return this.model?.uri.withPath(resourceUri.path);
|
|
176
191
|
}
|
|
177
192
|
|
|
178
193
|
undo(): void {
|
|
@@ -186,25 +201,24 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
|
|
|
186
201
|
protected render(): ReactNode {
|
|
187
202
|
if (this._model) {
|
|
188
203
|
return <div className='theia-notebook-main-container'>
|
|
189
|
-
{this.notebookMainToolbarRenderer.render(this._model)}
|
|
190
|
-
<
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
204
|
+
{this.notebookMainToolbarRenderer.render(this._model, this.node)}
|
|
205
|
+
<div className='theia-notebook-viewport' ref={(ref: HTMLDivElement) => this.viewportService.viewportElement = ref}>
|
|
206
|
+
<PerfectScrollbar className='theia-notebook-scroll-container'
|
|
207
|
+
onScrollY={(e: HTMLDivElement) => this.viewportService.onScroll(e)}>
|
|
208
|
+
<NotebookCellListView renderers={this.renderers}
|
|
209
|
+
notebookModel={this._model}
|
|
210
|
+
toolbarRenderer={this.cellToolbarFactory}
|
|
211
|
+
commandRegistry={this.commandRegistry} />
|
|
212
|
+
</PerfectScrollbar>
|
|
213
|
+
</div>
|
|
214
|
+
</div >;
|
|
197
215
|
} else {
|
|
198
216
|
return <div></div>;
|
|
199
217
|
}
|
|
200
218
|
}
|
|
201
219
|
|
|
202
|
-
protected override
|
|
203
|
-
super.
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
protected override onAfterDetach(msg: Message): void {
|
|
207
|
-
super.onAfterDetach(msg);
|
|
220
|
+
protected override onCloseRequest(msg: Message): void {
|
|
221
|
+
super.onCloseRequest(msg);
|
|
208
222
|
this.notebookEditorService.removeNotebookEditor(this);
|
|
209
223
|
}
|
|
210
224
|
|
|
@@ -221,10 +235,22 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
|
|
|
221
235
|
}
|
|
222
236
|
|
|
223
237
|
override dispose(): void {
|
|
238
|
+
this.notebookContextManager.dispose();
|
|
224
239
|
this.onDidChangeModelEmitter.dispose();
|
|
225
240
|
this.onDidPostKernelMessageEmitter.dispose();
|
|
226
241
|
this.onDidReceiveKernelMessageEmitter.dispose();
|
|
227
242
|
this.onPostRendererMessageEmitter.dispose();
|
|
243
|
+
this.viewportService.dispose();
|
|
228
244
|
super.dispose();
|
|
229
245
|
}
|
|
246
|
+
|
|
247
|
+
protected override onAfterShow(msg: Message): void {
|
|
248
|
+
super.onAfterShow(msg);
|
|
249
|
+
this.notebookEditorService.notebookEditorFocusChanged(this, true);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
protected override onAfterHide(msg: Message): void {
|
|
253
|
+
super.onAfterHide(msg);
|
|
254
|
+
this.notebookEditorService.notebookEditorFocusChanged(this, false);
|
|
255
|
+
}
|
|
230
256
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import '../../src/browser/style/index.css';
|
|
17
17
|
|
|
18
18
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
19
|
-
import { OpenHandler, WidgetFactory } from '@theia/core/lib/browser';
|
|
19
|
+
import { KeybindingContribution, OpenHandler, WidgetFactory } from '@theia/core/lib/browser';
|
|
20
20
|
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
21
21
|
import { NotebookOpenHandler } from './notebook-open-handler';
|
|
22
22
|
import { CommandContribution, MenuContribution, ResourceResolver, } from '@theia/core';
|
|
@@ -31,8 +31,6 @@ import { NotebookCellToolbarFactory } from './view/notebook-cell-toolbar-factory
|
|
|
31
31
|
import { createNotebookModelContainer, NotebookModel, NotebookModelFactory, NotebookModelProps } from './view-model/notebook-model';
|
|
32
32
|
import { createNotebookCellModelContainer, NotebookCellModel, NotebookCellModelFactory, NotebookCellModelProps } from './view-model/notebook-cell-model';
|
|
33
33
|
import { createNotebookEditorWidgetContainer, NotebookEditorWidgetContainerFactory, NotebookEditorProps, NotebookEditorWidget } from './notebook-editor-widget';
|
|
34
|
-
import { NotebookCodeCellRenderer } from './view/notebook-code-cell-view';
|
|
35
|
-
import { NotebookMarkdownCellRenderer } from './view/notebook-markdown-cell-view';
|
|
36
34
|
import { NotebookActionsContribution } from './contributions/notebook-actions-contribution';
|
|
37
35
|
import { NotebookExecutionService } from './service/notebook-execution-service';
|
|
38
36
|
import { NotebookExecutionStateService } from './service/notebook-execution-state-service';
|
|
@@ -42,10 +40,9 @@ import { NotebookKernelHistoryService } from './service/notebook-kernel-history-
|
|
|
42
40
|
import { NotebookEditorWidgetService } from './service/notebook-editor-widget-service';
|
|
43
41
|
import { NotebookRendererMessagingService } from './service/notebook-renderer-messaging-service';
|
|
44
42
|
import { NotebookColorContribution } from './contributions/notebook-color-contribution';
|
|
45
|
-
import {
|
|
46
|
-
import { NotebookMainToolbarRenderer } from './view/notebook-main-toolbar';
|
|
43
|
+
import { NotebookMonacoTextModelService } from './service/notebook-monaco-text-model-service';
|
|
47
44
|
|
|
48
|
-
export default new ContainerModule(bind => {
|
|
45
|
+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
49
46
|
bind(NotebookColorContribution).toSelf().inSingletonScope();
|
|
50
47
|
bind(ColorContribution).toService(NotebookColorContribution);
|
|
51
48
|
|
|
@@ -74,14 +71,12 @@ export default new ContainerModule(bind => {
|
|
|
74
71
|
bind(NotebookCellActionContribution).toSelf().inSingletonScope();
|
|
75
72
|
bind(MenuContribution).toService(NotebookCellActionContribution);
|
|
76
73
|
bind(CommandContribution).toService(NotebookCellActionContribution);
|
|
74
|
+
bind(KeybindingContribution).toService(NotebookCellActionContribution);
|
|
77
75
|
|
|
78
76
|
bind(NotebookActionsContribution).toSelf().inSingletonScope();
|
|
79
77
|
bind(CommandContribution).toService(NotebookActionsContribution);
|
|
80
78
|
bind(MenuContribution).toService(NotebookActionsContribution);
|
|
81
|
-
|
|
82
|
-
bind(NotebookCodeCellRenderer).toSelf().inSingletonScope();
|
|
83
|
-
bind(NotebookMarkdownCellRenderer).toSelf().inSingletonScope();
|
|
84
|
-
bind(NotebookMainToolbarRenderer).toSelf().inSingletonScope();
|
|
79
|
+
bind(KeybindingContribution).toService(NotebookActionsContribution);
|
|
85
80
|
|
|
86
81
|
bind(NotebookEditorWidgetContainerFactory).toFactory(ctx => (props: NotebookEditorProps) =>
|
|
87
82
|
createNotebookEditorWidgetContainer(ctx.container, props).get(NotebookEditorWidget)
|
|
@@ -90,6 +85,8 @@ export default new ContainerModule(bind => {
|
|
|
90
85
|
createNotebookModelContainer(ctx.container, props).get(NotebookModel)
|
|
91
86
|
);
|
|
92
87
|
bind(NotebookCellModelFactory).toFactory(ctx => (props: NotebookCellModelProps) =>
|
|
93
|
-
createNotebookCellModelContainer(ctx.container, props
|
|
88
|
+
createNotebookCellModelContainer(ctx.container, props).get(NotebookCellModel)
|
|
94
89
|
);
|
|
90
|
+
|
|
91
|
+
bind(NotebookMonacoTextModelService).toSelf().inSingletonScope();
|
|
95
92
|
});
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import {
|
|
18
18
|
CellData, CellEditType, CellMetadataEdit, CellOutput, CellOutputItem, CellRange, NotebookCellContentChangeEvent,
|
|
19
19
|
NotebookCellInternalMetadata,
|
|
20
|
+
NotebookCellMetadata,
|
|
20
21
|
NotebookCellsChangeInternalMetadataEvent,
|
|
21
22
|
NotebookCellsChangeLanguageEvent,
|
|
22
23
|
NotebookCellsChangeMetadataEvent,
|
|
@@ -152,13 +153,24 @@ export interface CellReplaceEdit {
|
|
|
152
153
|
cells: CellData[];
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
export interface CellPartialMetadataEdit {
|
|
157
|
+
editType: CellEditType.PartialMetadata;
|
|
158
|
+
index: number;
|
|
159
|
+
metadata: NullablePartialNotebookCellMetadata;
|
|
160
|
+
}
|
|
161
|
+
|
|
155
162
|
export type ImmediateCellEditOperation = CellOutputEditByHandle | CellOutputItemEdit | CellPartialInternalMetadataEditByHandle; // add more later on
|
|
156
163
|
export type CellEditOperation = ImmediateCellEditOperation | CellReplaceEdit | CellOutputEdit |
|
|
157
|
-
CellMetadataEdit | CellLanguageEdit | DocumentMetadataEdit | CellMoveEdit; // add more later on
|
|
164
|
+
CellMetadataEdit | CellLanguageEdit | DocumentMetadataEdit | CellMoveEdit | CellPartialMetadataEdit; // add more later on
|
|
158
165
|
|
|
159
166
|
export type NullablePartialNotebookCellInternalMetadata = {
|
|
160
167
|
[Key in keyof Partial<NotebookCellInternalMetadata>]: NotebookCellInternalMetadata[Key] | null
|
|
161
168
|
};
|
|
169
|
+
|
|
170
|
+
export type NullablePartialNotebookCellMetadata = {
|
|
171
|
+
[Key in keyof Partial<NotebookCellMetadata>]: NotebookCellMetadata[Key] | null
|
|
172
|
+
};
|
|
173
|
+
|
|
162
174
|
export interface CellPartialInternalMetadataEditByHandle {
|
|
163
175
|
editType: CellEditType.PartialInternalMetadata;
|
|
164
176
|
handle: number;
|