@theia/notebook 1.53.0-next.55 → 1.53.0-next.64

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.
Files changed (78) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/index.d.ts +1 -0
  3. package/lib/browser/index.d.ts.map +1 -1
  4. package/lib/browser/index.js +1 -0
  5. package/lib/browser/index.js.map +1 -1
  6. package/lib/browser/notebook-frontend-module.d.ts.map +1 -1
  7. package/lib/browser/notebook-frontend-module.js +2 -0
  8. package/lib/browser/notebook-frontend-module.js.map +1 -1
  9. package/lib/browser/service/notebook-cell-editor-service.d.ts +16 -0
  10. package/lib/browser/service/notebook-cell-editor-service.d.ts.map +1 -0
  11. package/lib/browser/service/notebook-cell-editor-service.js +53 -0
  12. package/lib/browser/service/notebook-cell-editor-service.js.map +1 -0
  13. package/lib/browser/view/notebook-cell-editor.d.ts +2 -0
  14. package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -1
  15. package/lib/browser/view/notebook-cell-editor.js +12 -1
  16. package/lib/browser/view/notebook-cell-editor.js.map +1 -1
  17. package/lib/browser/view/notebook-code-cell-view.d.ts +2 -0
  18. package/lib/browser/view/notebook-code-cell-view.d.ts.map +1 -1
  19. package/lib/browser/view/notebook-code-cell-view.js +6 -1
  20. package/lib/browser/view/notebook-code-cell-view.js.map +1 -1
  21. package/lib/browser/view/notebook-markdown-cell-view.d.ts +2 -0
  22. package/lib/browser/view/notebook-markdown-cell-view.d.ts.map +1 -1
  23. package/lib/browser/view/notebook-markdown-cell-view.js +8 -3
  24. package/lib/browser/view/notebook-markdown-cell-view.js.map +1 -1
  25. package/package.json +7 -7
  26. package/src/browser/contributions/cell-operations.ts +44 -44
  27. package/src/browser/contributions/notebook-actions-contribution.ts +379 -379
  28. package/src/browser/contributions/notebook-cell-actions-contribution.ts +525 -525
  29. package/src/browser/contributions/notebook-color-contribution.ts +268 -268
  30. package/src/browser/contributions/notebook-context-keys.ts +113 -113
  31. package/src/browser/contributions/notebook-label-provider-contribution.ts +85 -85
  32. package/src/browser/contributions/notebook-outline-contribution.ts +114 -114
  33. package/src/browser/contributions/notebook-output-action-contribution.ts +82 -82
  34. package/src/browser/contributions/notebook-preferences.ts +92 -92
  35. package/src/browser/contributions/notebook-status-bar-contribution.ts +77 -77
  36. package/src/browser/contributions/notebook-undo-redo-handler.ts +41 -41
  37. package/src/browser/index.ts +28 -27
  38. package/src/browser/notebook-cell-resource-resolver.ts +130 -130
  39. package/src/browser/notebook-editor-widget-factory.ts +82 -82
  40. package/src/browser/notebook-editor-widget.tsx +330 -330
  41. package/src/browser/notebook-frontend-module.ts +121 -119
  42. package/src/browser/notebook-open-handler.ts +120 -120
  43. package/src/browser/notebook-output-utils.ts +119 -119
  44. package/src/browser/notebook-renderer-registry.ts +85 -85
  45. package/src/browser/notebook-type-registry.ts +54 -54
  46. package/src/browser/notebook-types.ts +186 -186
  47. package/src/browser/renderers/cell-output-webview.ts +33 -33
  48. package/src/browser/service/notebook-cell-editor-service.ts +56 -0
  49. package/src/browser/service/notebook-clipboard-service.ts +43 -43
  50. package/src/browser/service/notebook-context-manager.ts +162 -162
  51. package/src/browser/service/notebook-editor-widget-service.ts +101 -101
  52. package/src/browser/service/notebook-execution-service.ts +139 -139
  53. package/src/browser/service/notebook-execution-state-service.ts +311 -311
  54. package/src/browser/service/notebook-kernel-history-service.ts +124 -124
  55. package/src/browser/service/notebook-kernel-quick-pick-service.ts +479 -479
  56. package/src/browser/service/notebook-kernel-service.ts +357 -357
  57. package/src/browser/service/notebook-model-resolver-service.ts +160 -160
  58. package/src/browser/service/notebook-monaco-text-model-service.ts +48 -48
  59. package/src/browser/service/notebook-options.ts +155 -155
  60. package/src/browser/service/notebook-renderer-messaging-service.ts +121 -121
  61. package/src/browser/service/notebook-service.ts +215 -215
  62. package/src/browser/style/index.css +484 -483
  63. package/src/browser/view/notebook-cell-editor.tsx +276 -263
  64. package/src/browser/view/notebook-cell-list-view.tsx +279 -279
  65. package/src/browser/view/notebook-cell-toolbar-factory.tsx +102 -102
  66. package/src/browser/view/notebook-cell-toolbar.tsx +74 -74
  67. package/src/browser/view/notebook-code-cell-view.tsx +355 -350
  68. package/src/browser/view/notebook-find-widget.tsx +335 -335
  69. package/src/browser/view/notebook-main-toolbar.tsx +235 -235
  70. package/src/browser/view/notebook-markdown-cell-view.tsx +215 -208
  71. package/src/browser/view/notebook-viewport-service.ts +61 -61
  72. package/src/browser/view-model/notebook-cell-model.ts +473 -473
  73. package/src/browser/view-model/notebook-cell-output-model.ts +100 -100
  74. package/src/browser/view-model/notebook-model.ts +550 -550
  75. package/src/common/index.ts +18 -18
  76. package/src/common/notebook-common.ts +337 -337
  77. package/src/common/notebook-protocol.ts +35 -35
  78. package/src/common/notebook-range.ts +30 -30
@@ -1,130 +1,130 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { Event, Emitter, Resource, ResourceReadOptions, ResourceResolver, URI } from '@theia/core';
18
- import { inject, injectable } from '@theia/core/shared/inversify';
19
- import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
20
- import { CellUri } from '../common';
21
- import { NotebookService } from './service/notebook-service';
22
- import { NotebookCellModel } from './view-model/notebook-cell-model';
23
- import { NotebookModel } from './view-model/notebook-model';
24
-
25
- export class NotebookCellResource implements Resource {
26
-
27
- protected readonly onDidChangeContentsEmitter = new Emitter<void>();
28
- get onDidChangeContents(): Event<void> {
29
- return this.onDidChangeContentsEmitter.event;
30
- }
31
-
32
- get onDidChangeReadOnly(): Event<boolean | MarkdownString> | undefined {
33
- return this.notebook.onDidChangeReadOnly;
34
- }
35
-
36
- get readOnly(): boolean | MarkdownString | undefined {
37
- return this.notebook.readOnly;
38
- }
39
-
40
- protected cell: NotebookCellModel;
41
- protected notebook: NotebookModel;
42
-
43
- uri: URI;
44
-
45
- constructor(uri: URI, notebook: NotebookModel, cell: NotebookCellModel) {
46
- this.uri = uri;
47
- this.notebook = notebook;
48
- this.cell = cell;
49
- }
50
-
51
- readContents(options?: ResourceReadOptions | undefined): Promise<string> {
52
- return Promise.resolve(this.cell.source);
53
- }
54
-
55
- dispose(): void {
56
- this.onDidChangeContentsEmitter.dispose();
57
- }
58
-
59
- }
60
-
61
- @injectable()
62
- export class NotebookCellResourceResolver implements ResourceResolver {
63
-
64
- @inject(NotebookService)
65
- protected readonly notebookService: NotebookService;
66
-
67
- async resolve(uri: URI): Promise<Resource> {
68
- if (uri.scheme !== CellUri.cellUriScheme) {
69
- throw new Error(`Cannot resolve cell uri with scheme '${uri.scheme}'`);
70
- }
71
-
72
- const parsedUri = CellUri.parse(uri);
73
- if (!parsedUri) {
74
- throw new Error(`Cannot parse uri '${uri.toString()}'`);
75
- }
76
-
77
- const notebookModel = this.notebookService.getNotebookEditorModel(parsedUri.notebook);
78
-
79
- if (!notebookModel) {
80
- throw new Error(`No notebook found for uri '${parsedUri.notebook}'`);
81
- }
82
-
83
- const notebookCellModel = notebookModel.cells.find(cell => cell.handle === parsedUri.handle);
84
-
85
- if (!notebookCellModel) {
86
- throw new Error(`No cell found with handle '${parsedUri.handle}' in '${parsedUri.notebook}'`);
87
- }
88
-
89
- return new NotebookCellResource(uri, notebookModel, notebookCellModel);
90
- }
91
-
92
- }
93
-
94
- @injectable()
95
- export class NotebookOutputResourceResolver implements ResourceResolver {
96
-
97
- @inject(NotebookService)
98
- protected readonly notebookService: NotebookService;
99
-
100
- async resolve(uri: URI): Promise<Resource> {
101
- if (uri.scheme !== CellUri.outputUriScheme) {
102
- throw new Error(`Cannot resolve output uri with scheme '${uri.scheme}'`);
103
- }
104
-
105
- const parsedUri = CellUri.parseCellOutputUri(uri);
106
- if (!parsedUri) {
107
- throw new Error(`Cannot parse uri '${uri.toString()}'`);
108
- }
109
-
110
- const notebookModel = this.notebookService.getNotebookEditorModel(parsedUri.notebook);
111
-
112
- if (!notebookModel) {
113
- throw new Error(`No notebook found for uri '${parsedUri.notebook}'`);
114
- }
115
-
116
- const ouputModel = notebookModel.cells.flatMap(cell => cell.outputs).find(output => output.outputId === parsedUri.outputId);
117
-
118
- if (!ouputModel) {
119
- throw new Error(`No output found with id '${parsedUri.outputId}' in '${parsedUri.notebook}'`);
120
- }
121
-
122
- return {
123
- uri: uri,
124
- dispose: () => { },
125
- readContents: async () => ouputModel.outputs[0].data.toString(),
126
- readOnly: true,
127
- };
128
- }
129
-
130
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { Event, Emitter, Resource, ResourceReadOptions, ResourceResolver, URI } from '@theia/core';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
20
+ import { CellUri } from '../common';
21
+ import { NotebookService } from './service/notebook-service';
22
+ import { NotebookCellModel } from './view-model/notebook-cell-model';
23
+ import { NotebookModel } from './view-model/notebook-model';
24
+
25
+ export class NotebookCellResource implements Resource {
26
+
27
+ protected readonly onDidChangeContentsEmitter = new Emitter<void>();
28
+ get onDidChangeContents(): Event<void> {
29
+ return this.onDidChangeContentsEmitter.event;
30
+ }
31
+
32
+ get onDidChangeReadOnly(): Event<boolean | MarkdownString> | undefined {
33
+ return this.notebook.onDidChangeReadOnly;
34
+ }
35
+
36
+ get readOnly(): boolean | MarkdownString | undefined {
37
+ return this.notebook.readOnly;
38
+ }
39
+
40
+ protected cell: NotebookCellModel;
41
+ protected notebook: NotebookModel;
42
+
43
+ uri: URI;
44
+
45
+ constructor(uri: URI, notebook: NotebookModel, cell: NotebookCellModel) {
46
+ this.uri = uri;
47
+ this.notebook = notebook;
48
+ this.cell = cell;
49
+ }
50
+
51
+ readContents(options?: ResourceReadOptions | undefined): Promise<string> {
52
+ return Promise.resolve(this.cell.source);
53
+ }
54
+
55
+ dispose(): void {
56
+ this.onDidChangeContentsEmitter.dispose();
57
+ }
58
+
59
+ }
60
+
61
+ @injectable()
62
+ export class NotebookCellResourceResolver implements ResourceResolver {
63
+
64
+ @inject(NotebookService)
65
+ protected readonly notebookService: NotebookService;
66
+
67
+ async resolve(uri: URI): Promise<Resource> {
68
+ if (uri.scheme !== CellUri.cellUriScheme) {
69
+ throw new Error(`Cannot resolve cell uri with scheme '${uri.scheme}'`);
70
+ }
71
+
72
+ const parsedUri = CellUri.parse(uri);
73
+ if (!parsedUri) {
74
+ throw new Error(`Cannot parse uri '${uri.toString()}'`);
75
+ }
76
+
77
+ const notebookModel = this.notebookService.getNotebookEditorModel(parsedUri.notebook);
78
+
79
+ if (!notebookModel) {
80
+ throw new Error(`No notebook found for uri '${parsedUri.notebook}'`);
81
+ }
82
+
83
+ const notebookCellModel = notebookModel.cells.find(cell => cell.handle === parsedUri.handle);
84
+
85
+ if (!notebookCellModel) {
86
+ throw new Error(`No cell found with handle '${parsedUri.handle}' in '${parsedUri.notebook}'`);
87
+ }
88
+
89
+ return new NotebookCellResource(uri, notebookModel, notebookCellModel);
90
+ }
91
+
92
+ }
93
+
94
+ @injectable()
95
+ export class NotebookOutputResourceResolver implements ResourceResolver {
96
+
97
+ @inject(NotebookService)
98
+ protected readonly notebookService: NotebookService;
99
+
100
+ async resolve(uri: URI): Promise<Resource> {
101
+ if (uri.scheme !== CellUri.outputUriScheme) {
102
+ throw new Error(`Cannot resolve output uri with scheme '${uri.scheme}'`);
103
+ }
104
+
105
+ const parsedUri = CellUri.parseCellOutputUri(uri);
106
+ if (!parsedUri) {
107
+ throw new Error(`Cannot parse uri '${uri.toString()}'`);
108
+ }
109
+
110
+ const notebookModel = this.notebookService.getNotebookEditorModel(parsedUri.notebook);
111
+
112
+ if (!notebookModel) {
113
+ throw new Error(`No notebook found for uri '${parsedUri.notebook}'`);
114
+ }
115
+
116
+ const ouputModel = notebookModel.cells.flatMap(cell => cell.outputs).find(output => output.outputId === parsedUri.outputId);
117
+
118
+ if (!ouputModel) {
119
+ throw new Error(`No output found with id '${parsedUri.outputId}' in '${parsedUri.notebook}'`);
120
+ }
121
+
122
+ return {
123
+ uri: uri,
124
+ dispose: () => { },
125
+ readContents: async () => ouputModel.outputs[0].data.toString(),
126
+ readOnly: true,
127
+ };
128
+ }
129
+
130
+ }
@@ -1,82 +1,82 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { nls, URI } from '@theia/core';
18
- import { WidgetFactory, NavigatableWidgetOptions, LabelProvider } from '@theia/core/lib/browser';
19
- import { inject, injectable } from '@theia/core/shared/inversify';
20
- import { NotebookEditorWidget, NotebookEditorWidgetContainerFactory, NotebookEditorProps } from './notebook-editor-widget';
21
- import { NotebookService } from './service/notebook-service';
22
- import { NotebookModelResolverService } from './service/notebook-model-resolver-service';
23
-
24
- export interface NotebookEditorWidgetOptions extends NavigatableWidgetOptions {
25
- notebookType: string;
26
- }
27
-
28
- @injectable()
29
- export class NotebookEditorWidgetFactory implements WidgetFactory {
30
- readonly id: string = NotebookEditorWidget.ID;
31
-
32
- @inject(NotebookService)
33
- protected readonly notebookService: NotebookService;
34
-
35
- @inject(NotebookModelResolverService)
36
- protected readonly notebookModelResolver: NotebookModelResolverService;
37
-
38
- @inject(LabelProvider)
39
- protected readonly labelProvider: LabelProvider;
40
-
41
- @inject(NotebookEditorWidgetContainerFactory)
42
- protected readonly createNotebookEditorWidget: (props: NotebookEditorProps) => NotebookEditorWidget;
43
-
44
- async createWidget(options?: NotebookEditorWidgetOptions): Promise<NotebookEditorWidget> {
45
- if (!options) {
46
- throw new Error('no options found for widget. Need at least uri and notebookType');
47
- }
48
- const uri = new URI(options.uri);
49
-
50
- await this.notebookService.willOpenNotebook(options.notebookType);
51
-
52
- const editor = await this.createEditor(uri, options.notebookType);
53
-
54
- this.setLabels(editor, uri);
55
- const labelListener = this.labelProvider.onDidChange(event => {
56
- if (event.affects(uri)) {
57
- this.setLabels(editor, uri);
58
- }
59
- });
60
- editor.onDidDispose(() => labelListener.dispose());
61
- return editor;
62
- }
63
-
64
- protected async createEditor(uri: URI, notebookType: string): Promise<NotebookEditorWidget> {
65
- return this.createNotebookEditorWidget({
66
- uri,
67
- notebookType,
68
- notebookData: this.notebookModelResolver.resolve(uri, notebookType),
69
- });
70
- }
71
-
72
- protected setLabels(editor: NotebookEditorWidget, uri: URI): void {
73
- editor.title.caption = uri.path.fsPath();
74
- if (editor.model?.readOnly) {
75
- editor.title.caption += ` • ${nls.localizeByDefault('Read-only')}`;
76
- }
77
- const icon = this.labelProvider.getIcon(uri);
78
- editor.title.label = this.labelProvider.getName(uri);
79
- editor.title.iconClass = icon + ' file-icon';
80
- }
81
-
82
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { nls, URI } from '@theia/core';
18
+ import { WidgetFactory, NavigatableWidgetOptions, LabelProvider } from '@theia/core/lib/browser';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { NotebookEditorWidget, NotebookEditorWidgetContainerFactory, NotebookEditorProps } from './notebook-editor-widget';
21
+ import { NotebookService } from './service/notebook-service';
22
+ import { NotebookModelResolverService } from './service/notebook-model-resolver-service';
23
+
24
+ export interface NotebookEditorWidgetOptions extends NavigatableWidgetOptions {
25
+ notebookType: string;
26
+ }
27
+
28
+ @injectable()
29
+ export class NotebookEditorWidgetFactory implements WidgetFactory {
30
+ readonly id: string = NotebookEditorWidget.ID;
31
+
32
+ @inject(NotebookService)
33
+ protected readonly notebookService: NotebookService;
34
+
35
+ @inject(NotebookModelResolverService)
36
+ protected readonly notebookModelResolver: NotebookModelResolverService;
37
+
38
+ @inject(LabelProvider)
39
+ protected readonly labelProvider: LabelProvider;
40
+
41
+ @inject(NotebookEditorWidgetContainerFactory)
42
+ protected readonly createNotebookEditorWidget: (props: NotebookEditorProps) => NotebookEditorWidget;
43
+
44
+ async createWidget(options?: NotebookEditorWidgetOptions): Promise<NotebookEditorWidget> {
45
+ if (!options) {
46
+ throw new Error('no options found for widget. Need at least uri and notebookType');
47
+ }
48
+ const uri = new URI(options.uri);
49
+
50
+ await this.notebookService.willOpenNotebook(options.notebookType);
51
+
52
+ const editor = await this.createEditor(uri, options.notebookType);
53
+
54
+ this.setLabels(editor, uri);
55
+ const labelListener = this.labelProvider.onDidChange(event => {
56
+ if (event.affects(uri)) {
57
+ this.setLabels(editor, uri);
58
+ }
59
+ });
60
+ editor.onDidDispose(() => labelListener.dispose());
61
+ return editor;
62
+ }
63
+
64
+ protected async createEditor(uri: URI, notebookType: string): Promise<NotebookEditorWidget> {
65
+ return this.createNotebookEditorWidget({
66
+ uri,
67
+ notebookType,
68
+ notebookData: this.notebookModelResolver.resolve(uri, notebookType),
69
+ });
70
+ }
71
+
72
+ protected setLabels(editor: NotebookEditorWidget, uri: URI): void {
73
+ editor.title.caption = uri.path.fsPath();
74
+ if (editor.model?.readOnly) {
75
+ editor.title.caption += ` • ${nls.localizeByDefault('Read-only')}`;
76
+ }
77
+ const icon = this.labelProvider.getIcon(uri);
78
+ editor.title.label = this.labelProvider.getName(uri);
79
+ editor.title.iconClass = icon + ' file-icon';
80
+ }
81
+
82
+ }