@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,186 +1,186 @@
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 {
18
- CellData, CellEditType, CellMetadataEdit, CellOutput, CellOutputItem, CellRange, NotebookCellContentChangeEvent,
19
- NotebookCellInternalMetadata,
20
- NotebookCellMetadata,
21
- NotebookCellsChangeInternalMetadataEvent,
22
- NotebookCellsChangeLanguageEvent,
23
- NotebookCellsChangeMetadataEvent,
24
- NotebookCellsChangeType, NotebookCellTextModelSplice, NotebookDocumentMetadata
25
- } from '../common';
26
- import { NotebookCell } from './view-model/notebook-cell-model';
27
-
28
- export interface NotebookTextModelChangedEvent {
29
- readonly rawEvents: NotebookContentChangedEvent[];
30
- // readonly versionId: number;
31
- readonly synchronous?: boolean;
32
- readonly endSelectionState?: SelectionState;
33
- };
34
-
35
- export type NotebookContentChangedEvent = (NotebookCellsInitializeEvent<NotebookCell> | NotebookDocumentChangeMetadataEvent | NotebookCellContentChangeEvent |
36
- NotebookCellsModelChangedEvent<NotebookCell> | NotebookCellsModelMoveEvent<NotebookCell> | NotebookOutputChangedEvent | NotebookOutputItemChangedEvent |
37
- NotebookCellsChangeLanguageEvent | NotebookCellsChangeMetadataEvent |
38
- NotebookCellsChangeInternalMetadataEvent | NotebookDocumentUnknownChangeEvent); // & { transient: boolean };
39
-
40
- export interface NotebookCellsInitializeEvent<T> {
41
- readonly kind: NotebookCellsChangeType.Initialize;
42
- readonly changes: NotebookCellTextModelSplice<T>[];
43
- }
44
-
45
- export interface NotebookDocumentChangeMetadataEvent {
46
- readonly kind: NotebookCellsChangeType.ChangeDocumentMetadata;
47
- readonly metadata: NotebookDocumentMetadata;
48
- }
49
-
50
- export interface NotebookCellsModelChangedEvent<T> {
51
- readonly kind: NotebookCellsChangeType.ModelChange;
52
- readonly changes: NotebookCellTextModelSplice<T>[];
53
- }
54
-
55
- export interface NotebookModelWillAddRemoveEvent {
56
- readonly rawEvent: NotebookCellsModelChangedEvent<CellData>;
57
- };
58
-
59
- export interface NotebookCellsModelMoveEvent<T> {
60
- readonly kind: NotebookCellsChangeType.Move;
61
- readonly index: number;
62
- readonly length: number;
63
- readonly newIdx: number;
64
- readonly cells: T[];
65
- }
66
-
67
- export interface NotebookOutputChangedEvent {
68
- readonly kind: NotebookCellsChangeType.Output;
69
- readonly index: number;
70
- readonly outputs: CellOutput[];
71
- readonly append: boolean;
72
- }
73
-
74
- export interface NotebookOutputItemChangedEvent {
75
- readonly kind: NotebookCellsChangeType.OutputItem;
76
- readonly index: number;
77
- readonly outputId: string;
78
- readonly outputItems: CellOutputItem[];
79
- readonly append: boolean;
80
- }
81
-
82
- export interface NotebookDocumentUnknownChangeEvent {
83
- readonly kind: NotebookCellsChangeType.Unknown;
84
- }
85
-
86
- export enum SelectionStateType {
87
- Handle = 0,
88
- Index = 1
89
- }
90
-
91
- export interface SelectionHandleState {
92
- kind: SelectionStateType.Handle;
93
- primary: number | null;
94
- selections: number[];
95
- }
96
-
97
- export interface SelectionIndexState {
98
- kind: SelectionStateType.Index;
99
- focus: CellRange;
100
- selections: CellRange[];
101
- }
102
-
103
- export type SelectionState = SelectionHandleState | SelectionIndexState;
104
-
105
- export interface NotebookModelWillAddRemoveEvent {
106
- readonly newCellIds?: number[];
107
- readonly rawEvent: NotebookCellsModelChangedEvent<CellData>;
108
- };
109
-
110
- export interface CellOutputEdit {
111
- editType: CellEditType.Output;
112
- index: number;
113
- outputs: CellOutput[];
114
- deleteCount?: number;
115
- append?: boolean;
116
- }
117
-
118
- export interface CellOutputEditByHandle {
119
- editType: CellEditType.Output;
120
- handle: number;
121
- outputs: CellOutput[];
122
- deleteCount?: number;
123
- append?: boolean;
124
- }
125
-
126
- export interface CellOutputItemEdit {
127
- editType: CellEditType.OutputItems;
128
- items: CellOutputItem[];
129
- outputId: string;
130
- append?: boolean;
131
- }
132
-
133
- export interface CellLanguageEdit {
134
- editType: CellEditType.CellLanguage;
135
- index: number;
136
- language: string;
137
- }
138
-
139
- export interface DocumentMetadataEdit {
140
- editType: CellEditType.DocumentMetadata;
141
- metadata: NotebookDocumentMetadata;
142
- }
143
-
144
- export interface CellMoveEdit {
145
- editType: CellEditType.Move;
146
- index: number;
147
- length: number;
148
- newIdx: number;
149
- }
150
-
151
- export interface CellReplaceEdit {
152
- editType: CellEditType.Replace;
153
- index: number;
154
- count: number;
155
- cells: CellData[];
156
- }
157
-
158
- export interface CellPartialMetadataEdit {
159
- editType: CellEditType.PartialMetadata;
160
- index: number;
161
- metadata: NullablePartialNotebookCellMetadata;
162
- }
163
-
164
- export type ImmediateCellEditOperation = CellOutputEditByHandle | CellOutputItemEdit | CellPartialInternalMetadataEditByHandle; // add more later on
165
- export type CellEditOperation = ImmediateCellEditOperation | CellReplaceEdit | CellOutputEdit |
166
- CellMetadataEdit | CellLanguageEdit | DocumentMetadataEdit | CellMoveEdit | CellPartialMetadataEdit; // add more later on
167
-
168
- export type NullablePartialNotebookCellInternalMetadata = {
169
- [Key in keyof Partial<NotebookCellInternalMetadata>]: NotebookCellInternalMetadata[Key] | null
170
- };
171
-
172
- export type NullablePartialNotebookCellMetadata = {
173
- [Key in keyof Partial<NotebookCellMetadata>]: NotebookCellMetadata[Key] | null
174
- };
175
-
176
- export interface CellPartialInternalMetadataEditByHandle {
177
- editType: CellEditType.PartialInternalMetadata;
178
- handle: number;
179
- internalMetadata: NullablePartialNotebookCellInternalMetadata;
180
- }
181
-
182
- export interface NotebookCellOutputsSplice {
183
- start: number;
184
- deleteCount: number;
185
- newOutputs: CellOutput[];
186
- };
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 {
18
+ CellData, CellEditType, CellMetadataEdit, CellOutput, CellOutputItem, CellRange, NotebookCellContentChangeEvent,
19
+ NotebookCellInternalMetadata,
20
+ NotebookCellMetadata,
21
+ NotebookCellsChangeInternalMetadataEvent,
22
+ NotebookCellsChangeLanguageEvent,
23
+ NotebookCellsChangeMetadataEvent,
24
+ NotebookCellsChangeType, NotebookCellTextModelSplice, NotebookDocumentMetadata
25
+ } from '../common';
26
+ import { NotebookCell } from './view-model/notebook-cell-model';
27
+
28
+ export interface NotebookTextModelChangedEvent {
29
+ readonly rawEvents: NotebookContentChangedEvent[];
30
+ // readonly versionId: number;
31
+ readonly synchronous?: boolean;
32
+ readonly endSelectionState?: SelectionState;
33
+ };
34
+
35
+ export type NotebookContentChangedEvent = (NotebookCellsInitializeEvent<NotebookCell> | NotebookDocumentChangeMetadataEvent | NotebookCellContentChangeEvent |
36
+ NotebookCellsModelChangedEvent<NotebookCell> | NotebookCellsModelMoveEvent<NotebookCell> | NotebookOutputChangedEvent | NotebookOutputItemChangedEvent |
37
+ NotebookCellsChangeLanguageEvent | NotebookCellsChangeMetadataEvent |
38
+ NotebookCellsChangeInternalMetadataEvent | NotebookDocumentUnknownChangeEvent); // & { transient: boolean };
39
+
40
+ export interface NotebookCellsInitializeEvent<T> {
41
+ readonly kind: NotebookCellsChangeType.Initialize;
42
+ readonly changes: NotebookCellTextModelSplice<T>[];
43
+ }
44
+
45
+ export interface NotebookDocumentChangeMetadataEvent {
46
+ readonly kind: NotebookCellsChangeType.ChangeDocumentMetadata;
47
+ readonly metadata: NotebookDocumentMetadata;
48
+ }
49
+
50
+ export interface NotebookCellsModelChangedEvent<T> {
51
+ readonly kind: NotebookCellsChangeType.ModelChange;
52
+ readonly changes: NotebookCellTextModelSplice<T>[];
53
+ }
54
+
55
+ export interface NotebookModelWillAddRemoveEvent {
56
+ readonly rawEvent: NotebookCellsModelChangedEvent<CellData>;
57
+ };
58
+
59
+ export interface NotebookCellsModelMoveEvent<T> {
60
+ readonly kind: NotebookCellsChangeType.Move;
61
+ readonly index: number;
62
+ readonly length: number;
63
+ readonly newIdx: number;
64
+ readonly cells: T[];
65
+ }
66
+
67
+ export interface NotebookOutputChangedEvent {
68
+ readonly kind: NotebookCellsChangeType.Output;
69
+ readonly index: number;
70
+ readonly outputs: CellOutput[];
71
+ readonly append: boolean;
72
+ }
73
+
74
+ export interface NotebookOutputItemChangedEvent {
75
+ readonly kind: NotebookCellsChangeType.OutputItem;
76
+ readonly index: number;
77
+ readonly outputId: string;
78
+ readonly outputItems: CellOutputItem[];
79
+ readonly append: boolean;
80
+ }
81
+
82
+ export interface NotebookDocumentUnknownChangeEvent {
83
+ readonly kind: NotebookCellsChangeType.Unknown;
84
+ }
85
+
86
+ export enum SelectionStateType {
87
+ Handle = 0,
88
+ Index = 1
89
+ }
90
+
91
+ export interface SelectionHandleState {
92
+ kind: SelectionStateType.Handle;
93
+ primary: number | null;
94
+ selections: number[];
95
+ }
96
+
97
+ export interface SelectionIndexState {
98
+ kind: SelectionStateType.Index;
99
+ focus: CellRange;
100
+ selections: CellRange[];
101
+ }
102
+
103
+ export type SelectionState = SelectionHandleState | SelectionIndexState;
104
+
105
+ export interface NotebookModelWillAddRemoveEvent {
106
+ readonly newCellIds?: number[];
107
+ readonly rawEvent: NotebookCellsModelChangedEvent<CellData>;
108
+ };
109
+
110
+ export interface CellOutputEdit {
111
+ editType: CellEditType.Output;
112
+ index: number;
113
+ outputs: CellOutput[];
114
+ deleteCount?: number;
115
+ append?: boolean;
116
+ }
117
+
118
+ export interface CellOutputEditByHandle {
119
+ editType: CellEditType.Output;
120
+ handle: number;
121
+ outputs: CellOutput[];
122
+ deleteCount?: number;
123
+ append?: boolean;
124
+ }
125
+
126
+ export interface CellOutputItemEdit {
127
+ editType: CellEditType.OutputItems;
128
+ items: CellOutputItem[];
129
+ outputId: string;
130
+ append?: boolean;
131
+ }
132
+
133
+ export interface CellLanguageEdit {
134
+ editType: CellEditType.CellLanguage;
135
+ index: number;
136
+ language: string;
137
+ }
138
+
139
+ export interface DocumentMetadataEdit {
140
+ editType: CellEditType.DocumentMetadata;
141
+ metadata: NotebookDocumentMetadata;
142
+ }
143
+
144
+ export interface CellMoveEdit {
145
+ editType: CellEditType.Move;
146
+ index: number;
147
+ length: number;
148
+ newIdx: number;
149
+ }
150
+
151
+ export interface CellReplaceEdit {
152
+ editType: CellEditType.Replace;
153
+ index: number;
154
+ count: number;
155
+ cells: CellData[];
156
+ }
157
+
158
+ export interface CellPartialMetadataEdit {
159
+ editType: CellEditType.PartialMetadata;
160
+ index: number;
161
+ metadata: NullablePartialNotebookCellMetadata;
162
+ }
163
+
164
+ export type ImmediateCellEditOperation = CellOutputEditByHandle | CellOutputItemEdit | CellPartialInternalMetadataEditByHandle; // add more later on
165
+ export type CellEditOperation = ImmediateCellEditOperation | CellReplaceEdit | CellOutputEdit |
166
+ CellMetadataEdit | CellLanguageEdit | DocumentMetadataEdit | CellMoveEdit | CellPartialMetadataEdit; // add more later on
167
+
168
+ export type NullablePartialNotebookCellInternalMetadata = {
169
+ [Key in keyof Partial<NotebookCellInternalMetadata>]: NotebookCellInternalMetadata[Key] | null
170
+ };
171
+
172
+ export type NullablePartialNotebookCellMetadata = {
173
+ [Key in keyof Partial<NotebookCellMetadata>]: NotebookCellMetadata[Key] | null
174
+ };
175
+
176
+ export interface CellPartialInternalMetadataEditByHandle {
177
+ editType: CellEditType.PartialInternalMetadata;
178
+ handle: number;
179
+ internalMetadata: NullablePartialNotebookCellInternalMetadata;
180
+ }
181
+
182
+ export interface NotebookCellOutputsSplice {
183
+ start: number;
184
+ deleteCount: number;
185
+ newOutputs: CellOutput[];
186
+ };
@@ -1,33 +1,33 @@
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 { Disposable } from '@theia/core';
18
- import { NotebookCellModel } from '../view-model/notebook-cell-model';
19
- import { NotebookModel } from '../view-model/notebook-model';
20
-
21
- export const CellOutputWebviewFactory = Symbol('outputWebviewFactory');
22
-
23
- export type CellOutputWebviewFactory = (cell: NotebookCellModel, notebook: NotebookModel) => Promise<CellOutputWebview>;
24
-
25
- export interface CellOutputWebview extends Disposable {
26
-
27
- readonly id: string;
28
-
29
- render(): React.ReactNode;
30
-
31
- attachWebview(): void;
32
- isAttached(): boolean
33
- }
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 { Disposable } from '@theia/core';
18
+ import { NotebookCellModel } from '../view-model/notebook-cell-model';
19
+ import { NotebookModel } from '../view-model/notebook-model';
20
+
21
+ export const CellOutputWebviewFactory = Symbol('outputWebviewFactory');
22
+
23
+ export type CellOutputWebviewFactory = (cell: NotebookCellModel, notebook: NotebookModel) => Promise<CellOutputWebview>;
24
+
25
+ export interface CellOutputWebview extends Disposable {
26
+
27
+ readonly id: string;
28
+
29
+ render(): React.ReactNode;
30
+
31
+ attachWebview(): void;
32
+ isAttached(): boolean
33
+ }
@@ -0,0 +1,56 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 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 { Emitter, URI } from '@theia/core';
18
+ import { injectable } from '@theia/core/shared/inversify';
19
+ import { SimpleMonacoEditor } from '@theia/monaco/lib/browser/simple-monaco-editor';
20
+
21
+ @injectable()
22
+ export class NotebookCellEditorService {
23
+
24
+ protected onDidChangeCellEditorsEmitter = new Emitter<void>();
25
+ readonly onDidChangeCellEditors = this.onDidChangeCellEditorsEmitter.event;
26
+
27
+ protected onDidChangeFocusedCellEditorEmitter = new Emitter<SimpleMonacoEditor | undefined>();
28
+ readonly onDidChangeFocusedCellEditor = this.onDidChangeFocusedCellEditorEmitter.event;
29
+
30
+ protected currentActiveCell?: SimpleMonacoEditor;
31
+
32
+ protected currentCellEditors: Map<string, SimpleMonacoEditor> = new Map();
33
+
34
+ get allCellEditors(): SimpleMonacoEditor[] {
35
+ return Array.from(this.currentCellEditors.values());
36
+ }
37
+
38
+ editorCreated(uri: URI, editor: SimpleMonacoEditor): void {
39
+ this.currentCellEditors.set(uri.toString(), editor);
40
+ this.onDidChangeCellEditorsEmitter.fire();
41
+ }
42
+
43
+ editorDisposed(uri: URI): void {
44
+ this.currentCellEditors.delete(uri.toString());
45
+ this.onDidChangeCellEditorsEmitter.fire();
46
+ }
47
+
48
+ editorFocusChanged(editor?: SimpleMonacoEditor): void {
49
+ this.currentActiveCell = editor;
50
+ this.onDidChangeFocusedCellEditorEmitter.fire(editor);
51
+ }
52
+
53
+ getActiveCell(): SimpleMonacoEditor | undefined {
54
+ return this.currentActiveCell;
55
+ }
56
+ }
@@ -1,43 +1,43 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 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 { inject, injectable } from '@theia/core/shared/inversify';
18
- import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
19
- import { NotebookCellModel } from '../view-model/notebook-cell-model';
20
- import { environment } from '@theia/core';
21
- import { CellData } from '../../common';
22
-
23
- @injectable()
24
- export class NotebookClipboardService {
25
-
26
- protected copiedCell: CellData | undefined;
27
-
28
- @inject(ClipboardService)
29
- protected readonly clipboardService: ClipboardService;
30
-
31
- copyCell(cell: NotebookCellModel): void {
32
- this.copiedCell = cell.getData();
33
-
34
- if (environment.electron.is()) {
35
- this.clipboardService.writeText(cell.text);
36
- }
37
- }
38
-
39
- getCell(): CellData | undefined {
40
- return this.copiedCell;
41
- }
42
-
43
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 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 { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
19
+ import { NotebookCellModel } from '../view-model/notebook-cell-model';
20
+ import { environment } from '@theia/core';
21
+ import { CellData } from '../../common';
22
+
23
+ @injectable()
24
+ export class NotebookClipboardService {
25
+
26
+ protected copiedCell: CellData | undefined;
27
+
28
+ @inject(ClipboardService)
29
+ protected readonly clipboardService: ClipboardService;
30
+
31
+ copyCell(cell: NotebookCellModel): void {
32
+ this.copiedCell = cell.getData();
33
+
34
+ if (environment.electron.is()) {
35
+ this.clipboardService.writeText(cell.text);
36
+ }
37
+ }
38
+
39
+ getCell(): CellData | undefined {
40
+ return this.copiedCell;
41
+ }
42
+
43
+ }