@theia/notebook 1.46.0-next.226 → 1.46.0-next.233
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-preferences.d.ts +9 -1
- package/lib/browser/contributions/notebook-preferences.d.ts.map +1 -1
- package/lib/browser/contributions/notebook-preferences.js +53 -3
- package/lib/browser/contributions/notebook-preferences.js.map +1 -1
- package/lib/browser/notebook-frontend-module.d.ts.map +1 -1
- package/lib/browser/notebook-frontend-module.js +2 -0
- 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.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-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/package.json +7 -7
- package/src/browser/contributions/notebook-actions-contribution.ts +2 -2
- package/src/browser/contributions/notebook-preferences.ts +54 -2
- package/src/browser/notebook-frontend-module.ts +2 -0
- package/src/browser/service/notebook-editor-widget-service.ts +4 -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 +3 -2
- 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
|
@@ -45,17 +45,17 @@ export interface RendererMessaging extends Disposable {
|
|
|
45
45
|
@injectable()
|
|
46
46
|
export class NotebookRendererMessagingService implements Disposable {
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
protected readonly postMessageEmitter = new Emitter<RendererMessage>();
|
|
49
49
|
readonly onPostMessage = this.postMessageEmitter.event;
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
protected readonly willActivateRendererEmitter = new Emitter<string>();
|
|
52
52
|
readonly onWillActivateRenderer = this.willActivateRendererEmitter.event;
|
|
53
53
|
|
|
54
54
|
@inject(NotebookEditorWidgetService)
|
|
55
|
-
|
|
55
|
+
protected readonly editorWidgetService: NotebookEditorWidgetService;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
protected readonly activations = new Map<string /* rendererId */, undefined | RendererMessage[]>();
|
|
58
|
+
protected readonly scopedMessaging = new Map<string /* editorId */, RendererMessaging>();
|
|
59
59
|
|
|
60
60
|
receiveMessage(editorId: string | undefined, rendererId: string, message: unknown): Promise<boolean> {
|
|
61
61
|
if (editorId === undefined) {
|
|
@@ -101,7 +101,7 @@ export class NotebookRendererMessagingService implements Disposable {
|
|
|
101
101
|
return messaging;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
protected postMessage(editorId: string, rendererId: string, message: unknown): void {
|
|
105
105
|
if (!this.activations.has(rendererId)) {
|
|
106
106
|
this.prepare(rendererId);
|
|
107
107
|
}
|
|
@@ -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;
|