@theia/notebook 1.50.1 → 1.52.0
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/notebook-actions-contribution.js +2 -2
- package/lib/browser/contributions/notebook-actions-contribution.js.map +1 -1
- package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts.map +1 -1
- package/lib/browser/contributions/notebook-cell-actions-contribution.js +17 -9
- package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +1 -1
- package/lib/browser/contributions/notebook-preferences.d.ts +12 -1
- package/lib/browser/contributions/notebook-preferences.d.ts.map +1 -1
- package/lib/browser/contributions/notebook-preferences.js +61 -3
- package/lib/browser/contributions/notebook-preferences.js.map +1 -1
- package/lib/browser/notebook-editor-widget.d.ts.map +1 -1
- package/lib/browser/notebook-editor-widget.js +2 -1
- 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 +3 -1
- package/lib/browser/notebook-frontend-module.js.map +1 -1
- package/lib/browser/service/notebook-editor-widget-service.d.ts +5 -4
- package/lib/browser/service/notebook-editor-widget-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-editor-widget-service.js +3 -0
- package/lib/browser/service/notebook-editor-widget-service.js.map +1 -1
- package/lib/browser/service/notebook-execution-service.d.ts +2 -2
- package/lib/browser/service/notebook-execution-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-execution-service.js.map +1 -1
- package/lib/browser/service/notebook-execution-state-service.d.ts +13 -13
- package/lib/browser/service/notebook-execution-state-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-execution-state-service.js.map +1 -1
- package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts +5 -5
- package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-kernel-quick-pick-service.js.map +1 -1
- package/lib/browser/service/notebook-kernel-service.d.ts +4 -4
- package/lib/browser/service/notebook-kernel-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-kernel-service.js.map +1 -1
- package/lib/browser/service/notebook-options.d.ts +29 -0
- package/lib/browser/service/notebook-options.d.ts.map +1 -0
- package/lib/browser/service/notebook-options.js +129 -0
- package/lib/browser/service/notebook-options.js.map +1 -0
- package/lib/browser/service/notebook-renderer-messaging-service.d.ts +8 -6
- package/lib/browser/service/notebook-renderer-messaging-service.d.ts.map +1 -1
- package/lib/browser/service/notebook-renderer-messaging-service.js.map +1 -1
- package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -1
- package/lib/browser/view/notebook-cell-editor.js +2 -1
- package/lib/browser/view/notebook-cell-editor.js.map +1 -1
- package/lib/browser/view/notebook-cell-list-view.d.ts +1 -1
- package/lib/browser/view/notebook-cell-list-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-cell-list-view.js +10 -9
- package/lib/browser/view/notebook-cell-list-view.js.map +1 -1
- package/lib/browser/view/notebook-code-cell-view.d.ts +5 -4
- package/lib/browser/view/notebook-code-cell-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-code-cell-view.js +43 -19
- package/lib/browser/view/notebook-code-cell-view.js.map +1 -1
- package/lib/browser/view/notebook-markdown-cell-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-markdown-cell-view.js +5 -2
- package/lib/browser/view/notebook-markdown-cell-view.js.map +1 -1
- package/lib/browser/view-model/notebook-cell-model.js +3 -3
- package/lib/browser/view-model/notebook-cell-model.js.map +1 -1
- package/lib/browser/view-model/notebook-cell-output-model.d.ts +1 -1
- package/lib/browser/view-model/notebook-cell-output-model.d.ts.map +1 -1
- package/lib/browser/view-model/notebook-cell-output-model.js.map +1 -1
- package/lib/browser/view-model/notebook-model.d.ts +2 -0
- package/lib/browser/view-model/notebook-model.d.ts.map +1 -1
- package/lib/browser/view-model/notebook-model.js +6 -3
- package/lib/browser/view-model/notebook-model.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/contributions/notebook-actions-contribution.ts +2 -2
- package/src/browser/contributions/notebook-cell-actions-contribution.ts +16 -9
- package/src/browser/contributions/notebook-preferences.ts +64 -3
- package/src/browser/notebook-editor-widget.tsx +3 -1
- package/src/browser/notebook-frontend-module.ts +5 -3
- package/src/browser/service/notebook-editor-widget-service.ts +7 -4
- package/src/browser/service/notebook-execution-service.ts +2 -2
- package/src/browser/service/notebook-execution-state-service.ts +12 -12
- package/src/browser/service/notebook-kernel-quick-pick-service.ts +5 -5
- package/src/browser/service/notebook-kernel-service.ts +4 -4
- package/src/browser/service/notebook-options.ts +154 -0
- package/src/browser/service/notebook-renderer-messaging-service.ts +6 -6
- package/src/browser/style/index.css +26 -5
- package/src/browser/view/notebook-cell-editor.tsx +3 -1
- package/src/browser/view/notebook-cell-list-view.tsx +10 -9
- package/src/browser/view/notebook-code-cell-view.tsx +40 -20
- package/src/browser/view/notebook-markdown-cell-view.tsx +4 -2
- package/src/browser/view-model/notebook-cell-model.ts +4 -4
- package/src/browser/view-model/notebook-cell-output-model.ts +1 -1
- package/src/browser/view-model/notebook-model.ts +7 -3
|
@@ -26,6 +26,7 @@ import { DisposableCollection, OS } from '@theia/core';
|
|
|
26
26
|
import { NotebookViewportService } from './notebook-viewport-service';
|
|
27
27
|
import { BareFontInfo } from '@theia/monaco-editor-core/esm/vs/editor/common/config/fontInfo';
|
|
28
28
|
import { NOTEBOOK_CELL_CURSOR_FIRST_LINE, NOTEBOOK_CELL_CURSOR_LAST_LINE } from '../contributions/notebook-context-keys';
|
|
29
|
+
import { EditorExtensionsRegistry } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorExtensions';
|
|
29
30
|
|
|
30
31
|
interface CellEditorProps {
|
|
31
32
|
notebookModel: NotebookModel,
|
|
@@ -117,7 +118,8 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
|
|
|
117
118
|
editorNode,
|
|
118
119
|
monacoServices,
|
|
119
120
|
{ ...DEFAULT_EDITOR_OPTIONS, ...cell.editorOptions },
|
|
120
|
-
[[IContextKeyService, this.props.notebookContextManager.scopedStore]]
|
|
121
|
+
[[IContextKeyService, this.props.notebookContextManager.scopedStore]],
|
|
122
|
+
{ contributions: EditorExtensionsRegistry.getEditorContributions().filter(c => c.id !== 'editor.contrib.findController') });
|
|
121
123
|
this.toDispose.push(this.editor);
|
|
122
124
|
this.editor.setLanguage(cell.language);
|
|
123
125
|
this.toDispose.push(this.editor.getControl().onDidContentSizeChange(() => {
|
|
@@ -45,7 +45,7 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
|
|
|
45
45
|
|
|
46
46
|
protected toDispose = new DisposableCollection();
|
|
47
47
|
|
|
48
|
-
protected dragGhost: HTMLElement | undefined;
|
|
48
|
+
protected static dragGhost: HTMLElement | undefined;
|
|
49
49
|
|
|
50
50
|
constructor(props: CellListProps) {
|
|
51
51
|
super(props);
|
|
@@ -96,6 +96,10 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
|
|
|
96
96
|
this.props.notebookModel.setSelectedCell(cell, false);
|
|
97
97
|
}}
|
|
98
98
|
onDragStart={e => this.onDragStart(e, index, cell)}
|
|
99
|
+
onDragEnd={e => {
|
|
100
|
+
NotebookCellListView.dragGhost?.remove();
|
|
101
|
+
this.setState({ ...this.state, dragOverIndicator: undefined });
|
|
102
|
+
}}
|
|
99
103
|
onDragOver={e => this.onDragOver(e, cell)}
|
|
100
104
|
onDrop={e => this.onDrop(e, index)}
|
|
101
105
|
draggable={true}
|
|
@@ -137,14 +141,11 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
|
|
|
137
141
|
return;
|
|
138
142
|
}
|
|
139
143
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.dragGhost.appendChild(this.props.renderers.get(cell.cellKind)?.renderDragImage(cell) ?? document.createElement('div'));
|
|
146
|
-
document.body.appendChild(this.dragGhost);
|
|
147
|
-
event.dataTransfer.setDragImage(this.dragGhost, -10, 0);
|
|
144
|
+
NotebookCellListView.dragGhost = document.createElement('div');
|
|
145
|
+
NotebookCellListView.dragGhost.classList.add('theia-notebook-drag-ghost-image');
|
|
146
|
+
NotebookCellListView.dragGhost.appendChild(this.props.renderers.get(cell.cellKind)?.renderDragImage(cell) ?? document.createElement('div'));
|
|
147
|
+
document.body.appendChild(NotebookCellListView.dragGhost);
|
|
148
|
+
event.dataTransfer.setDragImage(NotebookCellListView.dragGhost, -10, 0);
|
|
148
149
|
|
|
149
150
|
event.dataTransfer.setData('text/theia-notebook-cell-index', index.toString());
|
|
150
151
|
event.dataTransfer.setData('text/plain', this.props.notebookModel.cells[index].source);
|
|
@@ -32,8 +32,9 @@ import { CommandRegistry, DisposableCollection, nls } from '@theia/core';
|
|
|
32
32
|
import { NotebookContextManager } from '../service/notebook-context-manager';
|
|
33
33
|
import { NotebookViewportService } from './notebook-viewport-service';
|
|
34
34
|
import { EditorPreferences } from '@theia/editor/lib/browser';
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
35
|
+
import { NotebookOptionsService } from '../service/notebook-options';
|
|
36
|
+
import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
|
|
37
|
+
import { MarkdownString } from '@theia/monaco-editor-core/esm/vs/base/common/htmlContent';
|
|
37
38
|
|
|
38
39
|
@injectable()
|
|
39
40
|
export class NotebookCodeCellRenderer implements CellRenderer {
|
|
@@ -64,7 +65,11 @@ export class NotebookCodeCellRenderer implements CellRenderer {
|
|
|
64
65
|
@inject(CommandRegistry)
|
|
65
66
|
protected readonly commandRegistry: CommandRegistry;
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
@inject(NotebookOptionsService)
|
|
69
|
+
protected readonly notebookOptionsService: NotebookOptionsService;
|
|
70
|
+
|
|
71
|
+
@inject(MarkdownRenderer)
|
|
72
|
+
protected readonly markdownRenderer: MarkdownRenderer;
|
|
68
73
|
|
|
69
74
|
render(notebookModel: NotebookModel, cell: NotebookCellModel, handle: number): React.ReactNode {
|
|
70
75
|
return <div>
|
|
@@ -81,7 +86,7 @@ export class NotebookCodeCellRenderer implements CellRenderer {
|
|
|
81
86
|
monacoServices={this.monacoServices}
|
|
82
87
|
notebookContextManager={this.notebookContextManager}
|
|
83
88
|
notebookViewportService={this.notebookViewportService}
|
|
84
|
-
fontInfo={this.
|
|
89
|
+
fontInfo={this.notebookOptionsService.editorFontInfo} />
|
|
85
90
|
<NotebookCodeCellStatus cell={cell} notebook={notebookModel}
|
|
86
91
|
commandRegistry={this.commandRegistry}
|
|
87
92
|
executionStateService={this.executionStateService}
|
|
@@ -102,28 +107,43 @@ export class NotebookCodeCellRenderer implements CellRenderer {
|
|
|
102
107
|
renderDragImage(cell: NotebookCellModel): HTMLElement {
|
|
103
108
|
const dragImage = document.createElement('div');
|
|
104
109
|
dragImage.className = 'theia-notebook-drag-image';
|
|
105
|
-
dragImage.
|
|
110
|
+
dragImage.style.width = this.notebookContextManager.context?.clientWidth + 'px';
|
|
111
|
+
dragImage.style.height = '100px';
|
|
112
|
+
dragImage.style.display = 'flex';
|
|
113
|
+
|
|
114
|
+
const fakeRunButton = document.createElement('span');
|
|
115
|
+
fakeRunButton.className = `${codicon('play')} theia-notebook-cell-status-item`;
|
|
116
|
+
dragImage.appendChild(fakeRunButton);
|
|
117
|
+
|
|
118
|
+
const fakeEditor = document.createElement('div');
|
|
119
|
+
dragImage.appendChild(fakeEditor);
|
|
120
|
+
const lines = cell.source.split('\n').slice(0, 5).join('\n');
|
|
121
|
+
const codeSequence = this.getMarkdownCodeSequence(lines);
|
|
122
|
+
const firstLine = new MarkdownString(`${codeSequence}${cell.language}\n${lines}\n${codeSequence}`, { supportHtml: true, isTrusted: false });
|
|
123
|
+
fakeEditor.appendChild(this.markdownRenderer.render(firstLine).element);
|
|
124
|
+
fakeEditor.classList.add('theia-notebook-cell-editor-container');
|
|
125
|
+
fakeEditor.style.padding = '10px';
|
|
106
126
|
return dragImage;
|
|
107
127
|
}
|
|
108
128
|
|
|
109
|
-
protected
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
protected getMarkdownCodeSequence(input: string): string {
|
|
130
|
+
// We need a minimum of 3 backticks to start a code block.
|
|
131
|
+
let longest = 2;
|
|
132
|
+
let current = 0;
|
|
133
|
+
for (let i = 0; i < input.length; i++) {
|
|
134
|
+
const char = input.charAt(i);
|
|
135
|
+
if (char === '`') {
|
|
136
|
+
current++;
|
|
137
|
+
if (current > longest) {
|
|
138
|
+
longest = current;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
current = 0;
|
|
142
|
+
}
|
|
113
143
|
}
|
|
114
|
-
return
|
|
144
|
+
return Array(longest + 1).fill('`').join('');
|
|
115
145
|
}
|
|
116
146
|
|
|
117
|
-
protected createFontInfo(): BareFontInfo {
|
|
118
|
-
return BareFontInfo.createFromRawSettings({
|
|
119
|
-
fontFamily: this.editorPreferences['editor.fontFamily'],
|
|
120
|
-
fontWeight: String(this.editorPreferences['editor.fontWeight']),
|
|
121
|
-
fontSize: this.editorPreferences['editor.fontSize'],
|
|
122
|
-
fontLigatures: this.editorPreferences['editor.fontLigatures'],
|
|
123
|
-
lineHeight: this.editorPreferences['editor.lineHeight'],
|
|
124
|
-
letterSpacing: this.editorPreferences['editor.letterSpacing'],
|
|
125
|
-
}, PixelRatio.value);
|
|
126
|
-
}
|
|
127
147
|
}
|
|
128
148
|
|
|
129
149
|
export interface NotebookCodeCellStatusProps {
|
|
@@ -44,8 +44,10 @@ export class NotebookMarkdownCellRenderer implements CellRenderer {
|
|
|
44
44
|
|
|
45
45
|
renderDragImage(cell: NotebookCellModel): HTMLElement {
|
|
46
46
|
const dragImage = document.createElement('div');
|
|
47
|
-
dragImage.
|
|
48
|
-
|
|
47
|
+
dragImage.style.width = this.notebookContextManager.context?.clientWidth + 'px';
|
|
48
|
+
const markdownString = new MarkdownStringImpl(cell.source, { supportHtml: true, isTrusted: true });
|
|
49
|
+
const markdownElement = this.markdownRenderer.render(markdownString).element;
|
|
50
|
+
dragImage.appendChild(markdownElement);
|
|
49
51
|
return dragImage;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -30,7 +30,7 @@ import { NotebookCellOutputsSplice } from '../notebook-types';
|
|
|
30
30
|
import { NotebookMonacoTextModelService } from '../service/notebook-monaco-text-model-service';
|
|
31
31
|
import { NotebookCellOutputModel } from './notebook-cell-output-model';
|
|
32
32
|
import { PreferenceService } from '@theia/core/lib/browser';
|
|
33
|
-
import {
|
|
33
|
+
import { NotebookPreferences } from '../contributions/notebook-preferences';
|
|
34
34
|
import { LanguageService } from '@theia/core/lib/browser/language-service';
|
|
35
35
|
|
|
36
36
|
export const NotebookCellModelFactory = Symbol('NotebookModelFactory');
|
|
@@ -245,13 +245,13 @@ export class NotebookCellModel implements NotebookCell, Disposable {
|
|
|
245
245
|
this._internalMetadata = this.props.internalMetadata ?? {};
|
|
246
246
|
|
|
247
247
|
this.editorOptions = {
|
|
248
|
-
lineNumbers: this.preferenceService.get(NOTEBOOK_LINE_NUMBERS)
|
|
248
|
+
lineNumbers: this.preferenceService.get(NotebookPreferences.NOTEBOOK_LINE_NUMBERS)
|
|
249
249
|
};
|
|
250
250
|
this.toDispose.push(this.preferenceService.onPreferenceChanged(e => {
|
|
251
|
-
if (e.preferenceName === NOTEBOOK_LINE_NUMBERS) {
|
|
251
|
+
if (e.preferenceName === NotebookPreferences.NOTEBOOK_LINE_NUMBERS) {
|
|
252
252
|
this.editorOptions = {
|
|
253
253
|
...this.editorOptions,
|
|
254
|
-
lineNumbers: this.preferenceService.get(NOTEBOOK_LINE_NUMBERS)
|
|
254
|
+
lineNumbers: this.preferenceService.get(NotebookPreferences.NOTEBOOK_LINE_NUMBERS)
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
257
|
}));
|
|
@@ -38,7 +38,7 @@ export class NotebookCellOutputModel implements Disposable {
|
|
|
38
38
|
return this.rawOutput.metadata;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
constructor(
|
|
41
|
+
constructor(protected rawOutput: CellOutput) { }
|
|
42
42
|
|
|
43
43
|
replaceData(rawData: CellOutput): void {
|
|
44
44
|
this.rawOutput = rawData;
|
|
@@ -34,6 +34,7 @@ import { inject, injectable, interfaces, postConstruct } from '@theia/core/share
|
|
|
34
34
|
import { UndoRedoService } from '@theia/editor/lib/browser/undo-redo-service';
|
|
35
35
|
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
|
|
36
36
|
import type { NotebookModelResolverService } from '../service/notebook-model-resolver-service';
|
|
37
|
+
import { BinaryBuffer } from '@theia/core/lib/common/buffer';
|
|
37
38
|
|
|
38
39
|
export const NotebookModelFactory = Symbol('NotebookModelFactory');
|
|
39
40
|
|
|
@@ -176,8 +177,7 @@ export class NotebookModel implements Saveable, Disposable {
|
|
|
176
177
|
this.dirtyCells = [];
|
|
177
178
|
this.dirty = false;
|
|
178
179
|
|
|
179
|
-
const
|
|
180
|
-
const serializedNotebook = await this.props.serializer.fromNotebook(data);
|
|
180
|
+
const serializedNotebook = await this.serialize();
|
|
181
181
|
this.fileService.writeFile(this.uri, serializedNotebook);
|
|
182
182
|
|
|
183
183
|
this.onDidSaveNotebookEmitter.fire();
|
|
@@ -189,8 +189,12 @@ export class NotebookModel implements Saveable, Disposable {
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
serialize(): Promise<BinaryBuffer> {
|
|
193
|
+
return this.props.serializer.fromNotebook(this.getData());
|
|
194
|
+
}
|
|
195
|
+
|
|
192
196
|
async applySnapshot(snapshot: Saveable.Snapshot): Promise<void> {
|
|
193
|
-
const rawData =
|
|
197
|
+
const rawData = Saveable.Snapshot.read(snapshot);
|
|
194
198
|
if (!rawData) {
|
|
195
199
|
throw new Error('could not read notebook snapshot');
|
|
196
200
|
}
|